将嵌套子列表转换为平铺列表(单个节点处理)
当前处理的节点
获取子节点列表的函数,接收当前节点并返回其子节点数组
Optional
可选过滤器函数,返回true表示包含该节点
平铺后的节点数组
const tree = { id: 1, children: [ { id: 2, children: [] }, { id: 3, children: [{ id: 4, children: [] }] } ]};const flatList = listFlat(tree, node => node.children);// 返回: [tree, {id:2}, {id:3}, {id:4}] Copy
const tree = { id: 1, children: [ { id: 2, children: [] }, { id: 3, children: [{ id: 4, children: [] }] } ]};const flatList = listFlat(tree, node => node.children);// 返回: [tree, {id:2}, {id:3}, {id:4}]
将嵌套子列表转换为平铺列表(单个节点处理)