顺晟科技
2021-08-29 09:38:53
357
引入Qs库
Cnpm安装QS
Vue2.0 axios域之间的英尺
VUE axios域间问题no ' access-control-allow-origin ' header is present on the requested resource .
Cnpm安装QS
-组件。vue -
Import axios from 'axios '
Import QS from ' qs
Var data=qs.stringify({
TimeType: ' Month ',
Pointid : ' 40,30,31,34,39,43,35,29,38,26,27,28,36,41,42,32
开始时间:' 2019-4 ',
Endtime 3360 ' 2019-4 ',
DtBiDuiYear: ' 2018 ',
Factor: ' a34052 ',
});
Axios.post ('/getcomparedata ',data)
.then(function(response)){
console . log(response . status);
console . log(response . data);
})。
.catch(function(error)){
Console.log(错误);
});
- config/index.js转发代理-
ProxyTable: {
/GetSoilTypeInfo':{ //要代理的接口名称
目标:“要转发的接口”,//要代理的接口地址
ChangeOrigin:true,//允许跨域
path rewrite : { '/getsoiltypeinfo ' : ' }//重写接口名称
},
/gettreelistforsoilbyregion ' : {//要代理的接口名称
目标:“要转发的接口”,//要代理的接口地址
ChangeOrigin:true,//允许跨域
path rewrite : { '/gettreelistforsoilbyregion ' : ' }//重写接口名称
},
/GetCompareData':{ //要代理的接口名称
目标:“要转发的接口”,//要代理的接口地址
ChangeOrigin:true,//允许跨域
path rewrite : { '/getcomparedata ' : ' }//重写接口名称
}
},
02
2022-09
09
2022-04
29
2021-08
29
2021-08
28
2021-08
28
2021-08