美文网首页
vue中使用axios

vue中使用axios

作者: 呆呆_c007 | 来源:发表于2019-03-25 16:45 被阅读0次

安装依赖包

npm install axios --save

npm install qs --save

封装方法

封装get、post方法

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){})

相关文章

网友评论

      本文标题:vue中使用axios

      本文链接:https://www.haomeiwen.com/subject/exjbvqtx.html