升级到 vue3
This commit is contained in:
@@ -1,13 +1,25 @@
|
||||
import Vue from 'vue'
|
||||
import upperFirst from 'lodash/upperFirst'
|
||||
import camelCase from 'lodash/camelCase'
|
||||
|
||||
const requireComponent = require.context('./', true, /\.vue$/)
|
||||
|
||||
requireComponent.keys().forEach(fileName => {
|
||||
const componentConfig = requireComponent(fileName)
|
||||
const vueFileRxp = /\.vue$/
|
||||
|
||||
const componentName = upperFirst(camelCase(fileName.replace(/^\.\//, '').replace(/\.\w+$/, '')))
|
||||
export default app => {
|
||||
requireComponent.keys().forEach(fileName => {
|
||||
const filePath = fileName.replace(/^\.\//, '')
|
||||
|
||||
Vue.component(componentName, componentConfig.default || componentConfig)
|
||||
})
|
||||
if (!filePath.split('/').every((path, index, arr) => {
|
||||
const char = path.charAt(0)
|
||||
return vueFileRxp.test(path) || char.toUpperCase() !== char || arr[index + 1] == 'index.vue'
|
||||
})) return
|
||||
|
||||
const componentConfig = requireComponent(fileName)
|
||||
|
||||
let componentName = upperFirst(camelCase(filePath.replace(/\.\w+$/, '')))
|
||||
|
||||
if (componentName.endsWith('Index')) componentName = componentName.replace(/Index$/, '')
|
||||
|
||||
app.component(componentName, componentConfig.default || componentConfig)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user