🐛 修复组织级联回显时递归取整棵树导致栈溢出
This commit is contained in:
@@ -143,7 +143,9 @@ export default {
|
||||
for (const node of tree || []) {
|
||||
const path = [...parents, String(node.id)];
|
||||
if (String(node.id) === String(target)) return path;
|
||||
const matched = this.findOrgPath(target, node.children, path);
|
||||
// 必须显式传 node.children || []:叶节点的 children 是 undefined,
|
||||
// 传 undefined 会触发默认参数重新拿到整棵树,逐层重复扫描直到爆栈
|
||||
const matched = this.findOrgPath(target, node.children || [], path);
|
||||
if (matched) return matched;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user