白茶清风无别事  
 

1.结合vue-axios使用

    vue-axios是按照vue插件的方式去写的,那么结合vue-axios就可以使用Vue.use()这个方法import axios from 'axios'

import axios from 'axios';
import Vueaxios from 'vue-axios';

Vue.use(Vueaxios,axios)
methods:{
  delStudent:function(){
    this.axios.post(/WlCustomerWeChat/delStu).then((res)=>{
       console.log(res)
    }).catch((error)=>{
       console.log(error)
    })
  }
} 

  

2.引入axios之后改变axios的原型链

    axiso不能直接使用Vue.use(),只能在这个要发送请求的组件中引入,此方法是将axiso挂在vue的原型链上

import axios from 'axios';

Vue.prototype.$ajsx = axios
methods:{
  getStudent:function(){
    this.$ajax.get(/WlCustomerWeChat/getStu).then((res)=>{
       console.log(res)
    }).catch((error)=>{
       console.log(error)
    })
  }
}

 

posted on 2019-02-18 10:51  _Pluto  阅读(328)  评论(0)    收藏  举报