@corgicoding/axios-hook
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

@corgicoding/axios-hook

@corgicoding/web-quick-start 工程模板设定的组件库 axios 实例获取

逻辑

通过判断是否有以下两种参数,否则返回默认 axios

  1. axios-instance 参数 inject
  2. 获取当前页面是否挂载了全局 $http

使用

  1. 在外部工程需满足以下
app.provide('axios-instance', axios);
  1. 如果使用 el-libs 则在引入时配置
import httpInstance from '@/services/http/index';
import WELLComponent from '@corgicoding/el-libs';
import '@corgicoding/el-libs/lib/style.css';

app.use(WELLComponent, {
  global: false,
  axios: httpInstance,
  prefixCode: import.meta.env.VITE_PLATFORM_CODE || '',
  rules: validateActionPermission
});

Package Sidebar

Install

npm i @corgicoding/axios-hook

Weekly Downloads

4

Version

2.1.1

License

Apache-2.0

Unpacked Size

85.8 kB

Total Files

6

Last publish

Collaborators

  • charleschan2016