-
Notifications
You must be signed in to change notification settings - Fork 12
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
1 parent
3882fbd
commit 6c20670
Showing
7 changed files
with
104 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import piTools from './tools' | ||
|
||
const install = Vue => { | ||
console.log('piui 已安装') | ||
console.log('piui tools已挂载,使用方法:this.$piTools.', piTools) | ||
Vue.prototype.$piTools = piTools | ||
} | ||
|
||
export default install |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* 动态import文件 | ||
* @param {*} context require.context | ||
* @param {*} excludeIndexJs 是否排除index文件 | ||
*/ | ||
export const dynamicImport = (context, excludeIndex = true) => { | ||
const importFileMap = {} | ||
for (const key of context.keys()) { | ||
const keyArray = key.split('/') | ||
keyArray.shift() // 移除 | ||
const name = keyArray | ||
.join('.') | ||
.replace(/\.js$/g, '') | ||
.replace(/-(\w)/g, (_, c) => (c ? c.toUpperCase() : '')) | ||
if (excludeIndex && key === 'index') return | ||
importFileMap[name] = context(key) | ||
} | ||
return importFileMap | ||
} | ||
|
||
/** | ||
* 默认导出导入本目录下,排除index.js的所有js | ||
*/ | ||
export default dynamicImport(require.context('./', false, /\.js$/)) |
File renamed without changes.
File renamed without changes.
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