**
*在vue 2
**
在config文件下的index.js下
vue3是在vue.config.js中
代码如下
module.exports = {
devServer: {
host: 'localhost',//设置前端地址
port: 8083,//前端的端口
https: false,//不显示https
open: true,//运行完打开页面
hotOnly: false,
// 配置多个代理
proxy: 'http://localhost:18001'//代理后端的接口路径
//也可以采用下面的方式请求
// proxy: {
// '/sys': {
// target: 'http://localhost:18001',
// changeOrigin: true,
// wx: true
// }
// }
// lintOnSave: false // 取消 eslint 验证
}
}
之后在main.js下去设置axios请求地址
axios.defaults.baseURL = '接口拼接的地址'