const modules = require.context('./', true, /(/index.js$)/), blacklist = [ // 黑名单配置:组件name值 ]; let moduleList = []; modules.keys().filter(v => v.match(///g).length === 2).map(v => { moduleList.push(modules(v).default) }) moduleList = moduleList.filter(v => !blacklist.includes(v.name)); export default moduleList;