安装依赖包
npm install axios --save
npm install qs --save
封装方法

main.js中导入方法
import {get,post}from '@/api/fetch'
Vue.prototype.get = get;
Vue.prototype.post = post;
使用封装的方法
let res = await this.get(url,{});
或者
this.get(url,{}).then(function(res){}).catch(function(err){})
网友评论