index.js
// 实现自动化导入子组件 const modules = require.context('./', false, /w+.vue$/) const res = {} modules.keys().forEach(filePath => { const key = filePath.replace(/^./(.*).w+$/, '$1') const component = modules(filePath).default res[key] = component }) export default res