Create base components loader
This commit is contained in:
parent
1ef087740f
commit
94ee722245
27
src/views/loadComponents.js
Normal file
27
src/views/loadComponents.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
'use strict'
|
||||
|
||||
import upperFirst from 'lodash/upperFirst'
|
||||
import camelCase from 'lodash/camelCase'
|
||||
|
||||
const requireComponent = require.context(
|
||||
'@/components',
|
||||
false,
|
||||
/Base[A-Z]\w+\.(vue|js)$/
|
||||
)
|
||||
|
||||
export default function(Vue) {
|
||||
requireComponent.keys().forEach(fileName => {
|
||||
const componentConfig = requireComponent(fileName)
|
||||
|
||||
const componentName = upperFirst(
|
||||
camelCase(fileName
|
||||
.split('/')
|
||||
.pop()
|
||||
.replace(/\.\w+$/, '')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Vue.component(componentName, componentConfig.default || componentConfig)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user