Detailed explanation of the idea of using promise encapsulation
First create three js files, namely core.js (core file) config.js (configuration file) index.js (entry file)
(1) First create an axios instance in the core file and write baseURl (request header) and timeout time. 2. Throw out a function to determine whether it is a
get request or a post request. 3. Encapsulate the way of returning the request. 4. In the core The encapsulation method of the request in the configuration file is introduced into the file; (
2) In the configuration file
1, the encapsulation request method 2, the encapsulation request path
(3) In the entry file 1, the core file and the configuration file are introduced 2, in an object Encapsulate a function
return to return the request method and request address and parameters; 3. Throw this object;(4) Finally, import the objects in the entry file into man.js, register it globally, Vue.prototype.$function name=function name
If you can see this blog do not understand how to package promise