Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@corgicoding/axios-hook

charleschan201622Apache-2.02.1.1TypeScript support: included

组件库为了获取 vue 模板实例设计的 hook

types, corgicoding, web, axios

readme

@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
});