import Vue from "vue";
/**
 * require.context(directory .useSubdirectories ,regExp )
 * directory :-读取文件路径
 * useSubdirectories :-是够遍历文件子目录
 * regExp :匹配文件正则
 */

function changeStr(str) {
  return str.charAt(str).toUpperCase() + str.slice(1)
}
const requireComponent = require.context("./", false, /\.vue$/);

requireComponent.keys().forEach((fileName) => {
  let config = requireComponent(fileName);
  let componentName = changeStr(
    fileName.replace(/\.\//, "").replace(/\.\w+$/, "")
  );
  Vue.component(componentName, config.default || config);
});

