本文鏈接: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