VUE动态加载路由是如何处理组件加载
作者:
supa同学 | 来源:发表于
2020-06-07 09:57 被阅读0次export const filterAsyncRouter = (routers) => { // 遍历后台传来的路由字符串,转换为组件对象
return routers.filter(router => {
if (router.component) {
const component = router.component
router.component = loadView(component)
}
if (router.children && router.children.length) {
router.children = filterAsyncRouter(router.children)
}
return true
})
}
export const loadView = (view) => {
return () => import(`@/views/${view}`)
}
本文标题:VUE动态加载路由是如何处理组件加载
本文链接:https://www.haomeiwen.com/subject/ghcnzhtx.html
网友评论