根据条件删除树结构的元素

// 过滤 遍历 递归
function filterTree(data) {
var newTree = data.filter(x => x.type == '1')
newTree.forEach(x => x.children && (x.children = filterTree(x.children)))
return newTree;
}


posted @ 2023-11-10 17:32  熊猫不唱歌  阅读(10)  评论(0编辑  收藏  举报