uniapp历史模式history配置

こ雲淡風輕ζ 提交于 2020-03-30 12:31:11

//我们使用hash模式时,打包线上,容易出现页面空白的情况,所以如下配置

 "h5" : {
        "devServer" : {
	"publicPath":"./"
            "https" : false,
            "port" : 3000,
            "disableHostCheck" : true,
            "proxy" : {
                "/api" : {
                    "target" : "https://m.shop.com",
                    "ws" : true,
                    "changOrigin" : true,
                    "pathRewrite" : {
                        "^/api" : ""
                    }
                }
            }
        },
}

  //但我们使用历史模式(history)模式的时候,不能用hash模式的配置

    "h5" : {
        "devServer" : {
			// "publicPath":"./"   //注意隐藏这行
            "https" : false,
            "port" : 3000,
            "disableHostCheck" : true,
            "proxy" : {
                "/api" : {
                    "target" : "m.shop.com",
                    // "target":"http://localhost:8080/hht_mall/",
                    "ws" : true,
                    "changOrigin" : true,
                    "pathRewrite" : {
                        "^/api" : ""
                    }
                }
            }
        },
        "router" : {
            "base" : "mall/website/",    //填写你的线上地址(如http://m.shop.com/mall/webiste/,线上根目录是http://m.shop.com,取得是根目录后的mall/website, 注意本地开发时需要隐藏这行
            "mode" : "history"
        },
}

  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!