// 递归
function loopChildren (arr, callback) {
if (!arr) return
arr.forEach(item => {
if (item.children && item.children.length > 0) {
loopChildren(item.children, callback)
}
callback(item)
})
}
const arr = [
{
path: '/group',
name: 'Group',
redirect: '/group/grouping',
meta: {
isShow: true,
title: '群组',
icon: 'el-icon-s-grid',
isLink: '',
isHide: false,
isKeepAlive: true,
isAffix: true,
isIframe: false,
},
component: () => import('../views/routerView/parent.vue'),
children:[
{
path: '/group/department',
name: 'Department',
meta: {
isShow: true,
title: '部门',
icon: 'el-icon-phone',
isLink: '',
isHide: false,
isKeepAlive: true,
isAffix: true,
isIframe: false,
},
component: () => import('../views/group/department.vue')
}
]
}
]
const newArr = []
// 递归填充
loopChildren(arr, item => {
const { path, meta: { title, icon, isShow, isLink, isIframe, children } } = item
newArr.push({
title,
icon,
path,
isShow,
isLink,
isIframe
})
})
console.log(newArr)
console