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

浙公网安备 33010602011771号