Use of Vue-resource and vue-async-data two plugins

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.