When the viewer reports such a mistake, it means that your request needs to cross the domain!
Here, I'm talking about using cross-domain issues in Webpack+vue-cli+vue-resource,
There is a configuration parameter called proxytable in the index.js file below the config file.
Proxytable: { '/restful ': { target: ' http://xxxxx/member/service/', changeorigin:true, pathrewrite:{//can not write ' ^/restful ': '/restful '}} ,
Changeorigin This parameter is set to True, it is possible to virtual a local proxy service to receive the request so that the cross-domain problem can be resolved target is the domain name of the interface you request
This can be written when the interface is called.
this. $http. Post (Commonurl + "/restful/member?op=getmember&access_token=111", { op: ' GetMember ', }). Then (response + = }, response = { }); },
related to API proxy Description, the use of this parameter.
Https://vuejs-templates.github.io/webpack/proxy.html
This parameter is mainly an address mapping table, you can set the complex URL simplification, for example, we want to request the address is API.XXXXXXXX.COM/LIST/1, can be set as follows:
Proxytable: { '/list ': { target: ' http://api.xxxxxxxx.com ', pathrewrite: {//Can not write ' ^/list ': '/ List '}} }
So when we write the URL, only written /list/1 can represent api.xxxxxxxx.com/list/1.
so how to solve the cross-domain problem? In fact, in the above ' list ' parameter, there is a changeorigin parameter, receive a Boolean value, if set to True, then the local will be a virtual server to receive your request and send you the request, This will not have cross-domain issues, of course, this only applies to the development environment. The added code is as follows:
Proxytable: { '/list ': { target: ' http://api.xxxxxxxx.com ', changeorigin:true, pathrewrite: { ' ^/list ': '/list '}}
Using proxytable to resolve cross-domain issues in Webpack+vue-cli+vue-resource