目录:
Vue-resource介绍
基本用法
用vue-resource发送jsonp请求
一、Vue-resource介绍
使用Vue-resource发送跨域请求,安装vue-resource并引入
cnpm install vue-resource -S
或者自己手动下载vue-resource.min.js
Vue-resouce其实跟axios是一样的,但是官方建议使用axios,但是大部分公司还在用vue-resouce,因为axios不支持 jsonp跨域请求,但是vue-resource支持的。
我们查看一下 vue-resource的github的官方地址:
如图:
二、基本用法
使用this.$http发送请求
this.$http.get(url, [config])
this.$http.head(url, [config])
this.$http.delete(url, [config])
this.$http.jsonp(url, [config])
this.$http.post(url, [body], [config])
this.$http.put(url, [body], [config])
this.$http.patch(url, [body], [config])
三、用vue-resource发送jsonp请求
2.1、语法
说明:当你引入vue-resource是,则vue实例对象中$http,其实这个$http就是指