Mive views/loadComponents to components/_globals
This commit is contained in:
parent
9792439b13
commit
6269d07d01
21
src/components/_globals.ts
Normal file
21
src/components/_globals.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict'
|
||||
|
||||
import Vue from 'vue';
|
||||
import { upperFirst } from 'lodash'
|
||||
import { camelCase } from 'lodash'
|
||||
|
||||
const requireComponent = require.context(
|
||||
'./globals',
|
||||
false,
|
||||
/Base[A-Z]\w+\.(vue|js)$/
|
||||
)
|
||||
|
||||
requireComponent.keys().forEach((fileName: string) => {
|
||||
const componentConfig = requireComponent(fileName)
|
||||
const componentName = upperFirst(
|
||||
camelCase(
|
||||
fileName.replace(/^\.\/(.*)\.\w+$/, '$1')
|
||||
)
|
||||
)
|
||||
Vue.component(componentName, componentConfig.default || componentConfig)
|
||||
})
|
|
@ -1,23 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
import Vue from 'vue';
|
||||
import { upperFirst } from 'lodash'
|
||||
import { camelCase } from 'lodash'
|
||||
|
||||
const requireComponent = require.context(
|
||||
'@/components',
|
||||
false,
|
||||
/Base[A-Z]\w+\.(vue|js)$/
|
||||
)
|
||||
|
||||
export default function() {
|
||||
requireComponent.keys().forEach((fileName: string) => {
|
||||
const componentConfig = requireComponent(fileName)
|
||||
const componentName = upperFirst(
|
||||
camelCase(
|
||||
fileName.replace(/^\.\/(.*)\.\w+$/, '$1')
|
||||
)
|
||||
)
|
||||
Vue.component(componentName, componentConfig.default || componentConfig)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user