require.context读取文件获取动态路由

const excludes = ['./index.js']

const context = require.context('./filepath',true,/\.js/)

const routerMap = context.keys().filter( url => { return excludes.index(url) === -1}).map( url=> context(url).default)

posted @ 2020-03-13 17:36  不服憋着  阅读(923)  评论(0编辑  收藏  举报