对 Axios 进行封装

html

建立实例

可使用自定义配置新建一个 axios 实例vue

axios.create([config])ios

let instance = axios.create({
    baseURL: 'http://xxx',
    timeout: 1000,
    headers: {'X-Custom-Header': 'foobar'}
});
复制代码

请求配置

这些是建立请求时能够用的配置选项。只有 url 是必需的。若是没有指定 method,请求将默认使用 get 方法。axios

复制代码

配合 qs 库

常规封装参考:bash

vue中axios的封装ui

把axios封装为vue插件使用url

相关文章
相关标签/搜索