在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
复制代码
常规封装参考:bash