1. 程式人生 > >vue-resource使用

vue-resource使用

port post請求 bsp url his mounted ucc 使用 mount

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){});

}

}

vue-resource使用