|
1 |
| -import { kebabCase } from 'lodash' |
2 |
| -import { createApp } from 'vue' |
3 |
| -import { createFromIconfontCN } from '@ant-design/icons-vue' |
4 |
| -import { StaticConfig } from '@/config/app' |
5 |
| -// iconfont的使用姿势: 2x.antdv.com/components/icon-cn/#components-icon-demo-use-iconfont.cn |
6 |
| -const IconFont: any = createFromIconfontCN({ |
7 |
| - scriptUrl: StaticConfig.IconfontURL |
8 |
| -}) |
9 |
| - |
10 |
| -/** |
11 |
| - * @description 自动将 ./src/components/global 下的组件注册成为全局组件 |
12 |
| - * @param {vue} app 当前应用实例 |
13 |
| - * @returns {void} void |
14 |
| - */ |
15 |
| -export function registeGlobalComponent(app: ReturnType<typeof createApp>): void { |
16 |
| - const files = require.context('./global', true, /\.(vue|ts)$/) |
17 |
| - files.keys().forEach(key => { |
18 |
| - const config = files(key) |
19 |
| - console.log(key) |
20 |
| - const name = kebabCase(key.replace(/^\.\//, '').replace(/\.\w+$/, '')) |
21 |
| - app.component(name, config.default || config) |
22 |
| - }) |
23 |
| - |
24 |
| - // 全局注册 iconfont |
25 |
| - app.component('IconFont', IconFont) |
26 |
| -} |
| 1 | +import { kebabCase } from 'lodash' |
| 2 | +import { createApp } from 'vue' |
| 3 | +import { createFromIconfontCN } from '@ant-design/icons-vue' |
| 4 | +import { StaticConfig } from '@/config/app' |
| 5 | +// iconfont的使用姿势: 2x.antdv.com/components/icon-cn/#components-icon-demo-use-iconfont.cn |
| 6 | +const IconFont: any = createFromIconfontCN({ |
| 7 | + scriptUrl: StaticConfig.IconfontURL |
| 8 | +}) |
| 9 | + |
| 10 | +/** |
| 11 | + * @description 自动将 ./src/components/global 下的组件注册成为全局组件 |
| 12 | + * @param {vue} app 当前应用实例 |
| 13 | + * @returns {void} void |
| 14 | + */ |
| 15 | +export function registeGlobalComponent(app: ReturnType<typeof createApp>): void { |
| 16 | + const files = require.context('./global', true, /\.(vue|ts)$/) |
| 17 | + files.keys().forEach(key => { |
| 18 | + const config = files(key) |
| 19 | + const name = kebabCase(key.replace(/^\.\//, '').replace(/\.\w+$/, '')) |
| 20 | + app.component(name, config.default || config) |
| 21 | + }) |
| 22 | + |
| 23 | + // 全局注册 iconfont |
| 24 | + app.component('IconFont', IconFont) |
| 25 | +} |
0 commit comments