美文网首页
Vue-resourse

Vue-resourse

作者: 会飞的小北 | 来源:发表于2018-11-10 16:31 被阅读0次

大体的归类一下vue-resourse的资料

API

get(url,[options ])

head(url,[ options  ])

delete(url,[ options  ])

jsonp(url,[ options  ])

post(url,[ body ],[ options  ])

put(url,[ body ],[ options  ])

catch(url,[ body ],[ options  ])

这里我只是举几个简单的例子来讲解Get请求Post请求 JSONP请求以及全局拦截器的使用

get请求

这里面是get请求,Vue实例化之后这里的this值得就是vue所以实际请求之后直接this.$http.get('url',[options])就可以了

header的解释说明,其中header中注入的tocken是很有用的这里先简单的提一下

Request UPL请求的地址

Request Method请求的方法

Status Code请求的状态吗

我们在第三方注入的token也是存在的(res是包装的一个结构)

get请求:

post请求:

jsonp请求

最后一种方法http自己封装的数据请求

全局拦截器的使用

相关文章

网友评论

      本文标题:Vue-resourse

      本文链接:https://www.haomeiwen.com/subject/nmanxqtx.html