1、在项目 文件中创建一个vue.config.js文件,与src文件同级
2、找到Vue CLI 中的配置参考-链接->devServer.proxy模块
module.exports = {
devServer: {
proxy: {
// '/': { //此处'/'相当于target这个地址
target: 'http://localhost:8080',//直接写一句也可,默认==‘/’
//ws: true,
//changeOrigin: true
// },
}
}
}
注意:可能会报no-console错,请在package.json文件中配置:
"rules": {
"no-console": 0
},