Axios defaults to a method that does not have a JSONP cross-domain request. It is generally a popular practice to put the cross-domain in the background to resolve, that is, the background developers add cross-domain header information.
For example, in Java
Header,response.setheader ("Access-control-allow-origin", "www.allow-domain.com")
However, many times, the background for some reasons do not want to modify or have written JSONP interface needs to adapt to different platforms, at this point, the front-end can be introduced separately to solve the problem of dependency.
Introducing Dependencies
Install Jsonp
Import to Vue file
' Jsonp '
How to use it (refer to the documentation for JSONP on NPM)
Jsonp ("http://cross-domain.com",// replace URL { //JSONP callback function name name: ' Success_jsonpcallback ' }, // Note the first argument is err, the second parameter is the data function (err, data) { console.log (data); });
Vue using Axios to request data across domains