假设打包后的dist文件内容需要部署到非根目录http.xxx.com/m子路径下,解决步骤如下:
1、修改vue.config.js中的publicPath
module.exports = {
publicPath: "/m/", //打包后部署在一个子路径上http:xxx/m/
productionSourceMap: false,
devServer: {
proxy: "http://xxxx.com", //测试或正式环境域名和端口号
},
};
2、修改路由router的/index.js
const router = new VueRouter({
mode: "history",//路由模式
base: "/m/",//部署的子路径
routes,
});
export default router;
网友评论