码迷,mamicode.com
首页 > Web开发 > 详细

Vue http.get vue-resource

时间:2017-04-04 15:16:42      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:cti   callback   this   html   请求   回调   传统   pat   支持   

// 基于全局Vue对象使用http
Vue.http.get(‘/someUrl‘, [options]).then(successCallback, errorCallback);
Vue.http.post(‘/someUrl‘, [body], [options]).then(successCallback, errorCallback);
// 在一个Vue实例内使用$http
this.$http.get(‘/someUrl‘, [options]).then(successCallback, errorCallback);
this.$http.post(‘/someUrl‘, [body], [options]).then(successCallback, errorCallback);
// 传统写法
this.$http.get(‘/someUrl‘, [options]).then(function(response){
    // 响应成功回调
}, function(response){
    // 响应错误回调
});
支持的HTTP方法
vue-resource的请求API是按照REST风格设计的,它提供了7种请求API:

get(url, [options])
head(url, [options])
delete(url, [options])
jsonp(url, [options])
post(url, [body], [options])
put(url, [body], [options])
patch(url, [body], [options])

更多

http://www.cnblogs.com/axl234/p/5899137.html

Vue http.get vue-resource

标签:cti   callback   this   html   请求   回调   传统   pat   支持   

原文地址:http://www.cnblogs.com/jiaochengli/p/6664908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!