欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

vueaxios配置解析

程序员文章站 2022-09-21 23:06:26
vue axios配置 //main.js import axios from "axios"; vue.prototype.$axios = axios; //使用: //ge...

vue axios配置

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