-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
白唯
committed
Oct 13, 2020
1 parent
7affdf8
commit e11f13c
Showing
5 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import { kebabCase } from 'lodash' | ||
import { createApp } from 'vue' | ||
import { createFromIconfontCN } from '@ant-design/icons-vue' | ||
import { StaticConfig } from '@/config/app' | ||
// iconfont的使用姿势: 2x.antdv.com/components/icon-cn/#components-icon-demo-use-iconfont.cn | ||
const IconFont: any = createFromIconfontCN({ | ||
scriptUrl: StaticConfig.IconfontURL | ||
}) | ||
|
||
/** | ||
* @description 自动将 ./src/components/global 下的组件注册成为全局组件 | ||
* @param {vue} app 当前应用实例 | ||
* @returns {void} void | ||
*/ | ||
export function registeGlobalComponent(app: ReturnType<typeof createApp>): void { | ||
const files = require.context('./global', true, /\.vue$/) | ||
files.keys().forEach((key) => { | ||
const files = require.context('./global', true, /\.(vue|ts)$/) | ||
files.keys().forEach(key => { | ||
const config = files(key) | ||
console.log(key) | ||
const name = kebabCase(key.replace(/^\.\//, '').replace(/\.\w+$/, '')) | ||
app.component(name, config.default || config) | ||
}) | ||
|
||
// 全局注册 iconfont | ||
app.component('IconFont', IconFont) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters