本文链接:https://blog.csdn.net/u010394015/article/details/81460488
1、修改config/index.js里proxyTable
proxyTable: {
'/api': {
target: 'http://192.168.42.182:8080',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
},
}
1
2
3
4
5
6
7
8
9
2、修改config/dev.env.js
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API: '"/api"' // 加入这一句
})
1
2
3
4
3、设置axios的baseUrl
export default {
get (url, params) {
return axios({
method: 'get',
baseURL: process.env.API, // 修改这里
url,
params,
timeout: 100000
}).then((response) => {
return checkStatus(response)
}).then((res) => {
return checkCode(res)
})
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
4、重启服务器 npm run dev就好啦
————————————————
版权声明:本文为CSDN博主「、不知不觉、」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010394015/article/details/81460488