Skip to content

Latest commit

 

History

History

axios

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

简介

vitescv的axios模块

安装

pnpm add @vitescv/axios

使用

#在config.js中配置默认属性
modules:{
  ...
  "@vitescv/axios":{
    baseUrl:'/',
    timeout:0,
    headers:{
      common:{
        ...
      },
      post:{
        ...
      }
    }
  },
}

API

该模块扩展了vue实例,提供$axios属性可以访问, 也扩展了Context.axios,api参考官网

# in .vue
axios.get('/user?ID=12345')
  .then(function (response) {
    // 处理返回结果
  }.catch(function (error) {
    // 处理错误情况
    console.log(error);
  })
  .finally(function () {
    // 总是会执行
  });

# in module
Context.axios.get(xxx)