一.config下面index.js代理配置
proxyTable: {
'/api':{
target:'http://127.0.0.1:8088',
changeOrigin:true,
pathRewrite:{
'^/api': '/'
}
}
},
二.全局配置代理
import axios from 'axios';
Vue.prototype.axios = axios;
axios.defaults.baseURL = '/api';
三.实际请求
_self.axios.post("/queryMenu", {
lang: _self.newLang,
}).then(function(response){
_self.allData = response.data.hasOwnProperty("CN")?response.data.CN:response.data.EN;
console.log(_self.allData);
}).catch(function(error){
console.log(error);
});
四.注意说明
axios.defaults.baseURL = '/api';
每个请求都会带/api