vue-axios-get/post
安装axios
npm install axios -S
main.js中配置内容
import axios from 'axios'
页面中通过this.$axios调用
Vue.prototype.$axios = axios
配置qs解码(post)
import qs from 'qs'
Vue.prototype.$qs = qs
Get方式
this.$axios.get('url').then((res)=>{
console.log(res)
})
.catch((error)=>{
console.log(error)
})
post方式
let data = {
id: id2,
key: "houtai_beizhu",
value: word,
}
this.$axios({
method: 'post',
url: '',
data: this.$qs.stringify(data)
})
.then((res)=>{
console.log(res)
})
.catch(function (error) {
console.log(error);
});

浙公网安备 33010602011771号