index.vue文件
mounted: function() {
let _self = this;
_self.$axios.post('/abo/abbott/list',{
"stationName": "北土城"
},{
headers: {'Content-Type': 'application/x-www-form-urlencoded'} //加上这个
})
.then((res) => {
console.log('res == ', res);
// 成功后执行语句
})
.catch((err) =>{
// 网络中断或失败执行语句
})
}
代理的配置
proxyTable: {
'/abo/**': {
// target: 'http://129.28.127.53:8954/',
target: 'http://39.105.168.44:8021/',
changeOrigin: true,
pathRewrite: {
'^/abo': '/'
}
},
'/api/**': {
// target: 'http://129.28.127.53:8954/',
target: 'https://t.api.auto-pai.com',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
},
},
如果后台接口地址是
http://39.105.168.44:8021/abo/abbott/list
的话,这样写就行了:如果后台接口址是
http://39.105.168.44:8021/abbott/list
,才需要这样:最好前缀固定为
XX-api
,比如abo-api
。这样好标志是使用了代理。