npm install axios
main.js 里面
import axios from 'axios'
Vue.use(axios)
然后就在你要用的地方 直接 放在你的函数里面 或者方法里面
this.axios.post('你的调用接口', {
//你要传什么参数 写在这里面 举个例子
name: '二狗' ,
age: '100',
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
上面是很多方法中一种实现方式 其余的 自己看文档就行