第一步:安装一下path
npm install path --save
第二步:在vue.config.js文件中配置一下
const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
//跨域配置
devServer: {
proxy: {
'/java': {//以/java开头的地址会被替换成下面的target,/java本身会被重写成下面的pathRewrite
target: 'http://zaxytest.ciih.net/', // 后台api
changeOrigin: true, //是否跨域
// secure: true,
pathRewrite: {
'^/': '' //需要rewrite的,
}
}
}
},
//@路径配置
chainWebpack: config => {
config.resolve.alias
.set("@", resolve("src"))
.set("assets", resolve("src/assets"))
.set("components", resolve("src/components"))
.set("base", resolve("baseConfig"))
.set("public", resolve("public"));
},
};
第三步:重启服务
标签:src,set,java,resolve,项目,路径,Vue,path,config From: https://blog.51cto.com/u_14121041/6415409