动态引入以 xxxIndex.vue结尾的文件

154 阅读1分钟
// 动态引入以 xxxIndex.vue结尾的文件
let COMPONENTS: any = {};
const files = require.context('../', true, /Index.vue$/);
console.log(files.keys());
files.keys().map(key => {
  let component = files(key).default;
  COMPONENTS[component.name.toLowerCase()] = component;
});