vueresource使用

import VueResource from 'vue-resouce'

Vue.use(VueResource);

在组件内部调用:

export default {

mounted(){

  //get请求

  this.$http.get(url).then(function(success){

  // 这里的this 也属于该组件? 未使用箭头函数直接使用this,同样指向组件。。

  }, function(err){});

       // post请求
  this.$http.post(url, {/** 一些请求数据 */}).then(function(success){}, function(err){});

}

}

原文地址:https://www.cnblogs.com/tatelZhang/p/7726241.html