Vue-resource and Vue-async-data two plug-in use, looked at the document Http://cn.vuejs.org/guide/plugins.html#u5DF2_u6709_u63D2_u4EF6__26amp _3b__u5de5_u5177
varVue = require ("Vue"), App= Require ("./app.vue");varVueresource = require ('Vue-resource'); Vue.use (Vueresource);varVM =NewVue ({el:'Body', Ready:function () { This. $http.Get('./src/test.json', {}, {headers: {"X-requested-with":"XMLHttpRequest"}, Emulatejson:true}). Then (function (response) {vardata =Response.data; This. msg =data; }, function (response) {//Handle Error }); }, Data: {msg:"Hello", Dom:"Body" }});
Simply put, Vue-resource is like the $.ajax in jquery, used to interact with the backend data ... You can run it in created or ready to get or update the data ...
Vue-async-data should be a way to encapsulate the updated data, but still need vue-resource to do the interaction
varVue = require ("Vue"), App= Require ("./app.vue");varVueresource = require ('Vue-resource');varVueasyncdata = require ('Vue-async-data') Vue.use (Vueresource); Vue.use (vueasyncdata);varVM =NewVue ({el:'Body', Asyncdata:function (Resolve, reject) { This. $http.Get('./src/test.json', {}, {headers: {"X-requested-with":"XMLHttpRequest"}, Emulatejson:true}). Then (function (response) {vardata =Response.data; Resolve ({msg:data}); }, function (response) {//Handle Error }); }, Data: {msg:"Hello", Dom:"Body" }});
Use of Vue-resource and vue-async-data two plugins