//main.js
import Axios from "axios";
Vue.prototype.$axios = Axios;
//使用:
//get请求:
this.$axios
.get("apis/query", {
params: {
//参数
type: "yuantong",
postid: "111111111"
}
})
.then(res => {
console.log(res.data);
})
.catch(error => {
console.log(error);
});
//post请求:
//qs是第三方库,用来处理post参数
import qs from "qs";
this.$axios
.post(
"apis/query",
qs.stringify({
type: "yuantong",
postid: "111111111"
})
)
.then(res => {
console.log(res.data);
})
.catch(error => {
console.log(error);
});
vue axios配置
猜你喜欢
转载自blog.csdn.net/weixin_38639882/article/details/82144918
今日推荐
周排行