在vue-cli里面使用http-proxy-middleware post的数据没有传递到服务器,服务器一直返回空数据
在config/index.js
proxyTable: {
'/api': {
target: 'http://192.168.1.86:9999/web',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
配置了全局axios
import axios from 'axios';
Vue.prototype.$http = axios;
请求接口
let url = 'api/接口'
this.$http({
url: url,
method: 'post',
data: {
mobile: parseInt(this.phonenum),
type: 1
},
}).then(res => {})
.catch(err=>{})
能搞请求后台成功后,但是后台却没有接到数据
初始化配置axios,create一个新的service,设置头部,然后转换一下数据 就OK啦