function getAllIds(tree, result) {
//遍历树 获取id数组
for (const i in tree) {
result.push(tree[i].id); // 遍历项目满足条件后的操作
if (tree[i].children) {
//存在子节点就递归
getAllIds(tree[i].children, result);
}
}
return result;
}
```
代码记录遍历树并获取id
最新推荐文章于 2024-08-17 08:45:02 发布