Vue 分享3

来源:互联网 发布:虚荣辅助软件 编辑:程序博客网 时间:2024/05/16 17:00

vueResource 和 axios 与后端通信对比

1.vueResource 
(1)准备工作:
import VueResource from'vue-resource'
Vue.use(VueResource);
(2)使用:日常使用get和post方法
post:
get:


(3) 详情可以去看vue-resource gitHup:---> https://github.com/pagekit/vue-resource/blob/develop/docs/http.md

2.axios
(1)准备工作
import Axios from'axios'
Vue.prototype.$axios = Axios
(2)使用:日常的get和post请求(这里函数需要bind(this)否则没法获取到vm对象)
post:

get:

(3) githup网址附上:https://github.com/mzabriskie/axios