// 递归遍历数据获取当前实体名称
recursionChildren(arr, node) {
let name = "";
arr.forEach((item) => {
let temp = { ...item };
if (temp.children && temp.children.length > 0) {
if (temp.id == node) {
name = temp.label;
} else {
let result = this.recursionChildren(temp.children, node);
if (result) {
name = result;
}
}
} else {
if (temp.id == node) {
name = temp.label;
}
}
});
return name;
},
js递归调用&多层if else嵌套,返回值为空或undefined问题
猜你喜欢
转载自blog.csdn.net/song_song0927/article/details/132237592
今日推荐
周排行