getTree = (tree: any[] = [], map: any[] = [], arr: any[] = []) => {
console.info('tree:',tree)
if (!tree.length) return []
for (let item of tree) {
console.info(!map.includes(item.id))
if (map.includes(item.id)) continue
let node = { title: item.menuName, key: item.id, children: [] }
arr.push(node)
if (item.menuVoList && item.menuVoList.length) this.getTree(item.menuVoList, map, node.children)
}
return arr
}
类似树结构的数据:
let nodeList = [
{id: '1-1', children: [{id: '1-2-1'}, {id: '1-2-2'}]},
{id: '2-1'},
{id: '3-1', children: [{id: '3-2-1', children: [{id: '3-3-1'}]}]}
]