const loadRouter = (roleArr = [], router = {}) => { //动态加载路由
let arr = []
roleArr.map((item) => {
if (item.children.length == 0) {
arr.push({
path: ‘/’ + item.path,
name: item.path,
component: resolve => require([../../views/${item.path}
], resolve),//动态生成路由(江湖人称懒加载,此步) 非常重要!!!
meta: {
title: item.name,
requireAuth: item.requireAuth
}
})
} else {
item.children.map((n) => {
arr.push({
path: ‘/’ + n.path,
name: n.path,
comp
vue动态加载路由
最新推荐文章于 2024-07-03 17:18:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)