// 查找所有父节点
getAllParentArr(list, id) {
for (let i in list) {
if (list[i].id === id) {
//查询到返回该数组对象
return [list[i]];
}
if (list[i].children) {
let node = this.getAllParentArr(list[i].children, id);
if (node !== undefined) {
//查询到把父节点连起来
return node.concat(list[i]);
}
}
}
},
// 调用
let temptArr = [];
temptArr = this.getAllParentArr(this.treeNodeList, id);// 参数1:树形数据,参数2:节点id
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用。你还可以使用@来通知其他用户。