lookForAllId(data = [], arr = []) {
for (let item of data) {
arr.push(item.id);
if (item.children && item.children.length)
this.lookForAllId(item.children, arr);
}
return arr;
},
//调用
this.lookForAllId(this.treeArry) //treeArry是树形结构
js遍历树形结构并返回所有的子节点id值
阅读 73
2022-08-01
lookForAllId(data = [], arr = []) {
for (let item of data) {
arr.push(item.id);
if (item.children && item.children.length)
this.lookForAllId(item.children, arr);
}
return arr;
},
//调用
this.lookForAllId(this.treeArry) //treeArry是树形结构
相关推荐
精彩评论(0)