很是苦恼,改写的也都写了,一直都是localhost
另外项目也重启过了
main.js
import axios from 'axios'
Vue.prototype.$axios = axios;
Vue.prototype.HOST = "/api";
config / index.js
proxyTable: {
'api':{
target:'http://www.kuaidi100.com',
changeOrigin:true,
pathRewrite:{
'^/api':''
}
}
},
script:
created() {
let url = this.HOST + "/query";
this.$axios.get(url, {
params:{
type: 'yunda',
postid: 3916090104344
}
})
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error)
})
}
api要写成/api,因为你要代理的是/api