vue中axios封装

78 阅读1分钟

1、在src下新建request文件夹,文件夹下面有api.js和http.js

2、在api.js中封装axios,设置请求/响应拦截器

image.png 3、在http.js中二次封装

image.png

参考文档axios封装: