后台读取生成动态路由时,二级菜单注册component,一直无法成功。
如果component为Layout就可以成功。
错误:
TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.o
尝试关闭严格模式但是失败了。
代码:
export function addAsyncRouter(routers){
const accessedRouters = routers.filter(router => {
if (router.component) {
if (router.component === 'Layout') {
router.component = Layout
} else {
const component = router.component
router.component = () => import('@/views/' + component)
}
}
if (router.children && router.children.length) {
router.children = filterAsyncRouter(router.children)
}else{
router.children = []
}
return true
})
return accessedRouters
}
感觉是这句的问题
router.component = () => import("@/views/" + component)
之前还试过
router.component = resolve => require(["@/views/" + component], resolve)
也还是一样的问题
想请教各位大佬,这个还有别的格式么
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…