Since vue2.0 began to not maintain the vue-resouce, instead of Axios, Axios official documents written in detail, attached to a link: http://www.jianshu.com/p/df464b26ae58
But I have a question after reading, cross-domain requests? Where (black question mark face), in the vue-resouce inside also has HTTP.JSONP carries on the JSONP cross domain, but Axios, after the inquiry, is needs to open the agent only then.
First, we need to make proxy settings in the index of Webpack config:
Add the following code:
'/api ' refers to, if we want to cross-domain, you can use/API instead of ' HTTP://R.PENGYOU.COM/FCG-BIN/CGI_GET_PORTRAIT.FCG ' this interface, the rest of the options what meaning to read the comments
So, how do we use it, look at the picture:
At this point we can now cross-domain request, if still can't cross-domain, that need to work with the background of small brother, let him in the background to open cross-domain, I previously wrote the background cross-domain method: http://www.cnblogs.com/mmykdbc/p/8024105.html
OK, look at the effect:
is a string, then we use the usual json.parse to convert is not feasible, because this is a callback function, then how do we convert it, on-line check a lot of methods, the original JS or JQ did not handle the callback function, so I can only in Str, I could intercept {} Inside the content ah, that in the conversion can be, say half of it, the code is as follows:
Perfect access to data:
Remember, you must restart the project after the configuration is complete, the configuration must be restarted after the project, the configuration must be restarted after the project; important thing to say three times!!!
Axios How to perform cross-domain and processing of return format callback function strings