一,动态加载的方法
import { reduce, camelCase, upperFirst } from ‘lodash’
const files = require.context(‘./components’, true, /index.vue$/, ‘sync’)
console.log(‘files---->’, files.keys())
import Vue from ‘vue’
export const components = reduce(
files.keys(),
(result, key) => {
const m = files(key)
key = key.replace(‘./’, ‘’)
// console.log(‘—>nakeykeye’, key)
const name = upperFirst(camelCase(‘Verif-’ + key.substring(0, key.indexOf(‘/’))))
console.log(‘—>nakeykeye2’, name)
Vue.component(name, m.default)
// result[name] = m instanceof Promise ? () => m : m.default
return result
},
{}
)