In fact, they are not very different, are based on the es6 of Promise object Implementation method
Vue-resource:
Main.js =
Import vue from ' Vue ';
Import Vueresource from ' Vue-resource ';
Vue.use (Vueresource);
Components inside use = =
<Template> <Div>{{MyData}}</Div></Template><Script>Exportdefault{data () {return{mydata:{}}, created () { This. $http. Get (URL). Then (response)= { //Success This. MyData=Response.body.data; }, (Error)= { //ErrorConsole.log (Error)}); } }</Script>
Official portal
Vue-axios:
Axios cannot use the Using method
Main.js=>
Import vue from ' Vue ';
Import Axios from ' Axios ';
Vue.prototype. $axios = Axios;
Components inside use = =
<Template> <Div>{{MyData}}</Div></Template><Script>Exportdefault{data () {return{myData: {}}}, created () { This. $axios. Get (URL). Then (response)= { //Success This. MyData=Response.data.data; }, (Error)= { //ErrorConsole.log (Error)}); }</Script>
Official portal
Simple ways to use Vue-resource and Vue-axios