后端也返回了第四等级,但是不想让他展示,可以这样解决只展示前三等级
// 获取room树
getRoomTreeList() {
getRoomTree().then((res) => {
// 只获取到单元楼节点
function handleTreeData(data, limit = 3, count = 1) {
return data?.map((x) => ({
...x,
children:
count < limit ? handleTreeData(x.children, limit, count + 1) : [],
}));
}
this.treeData = handleTreeData(res.data);
});
},
},
};
标签:count,el,展示,tree,handleTreeData,limit,data,节点
From: https://www.cnblogs.com/xuelinomen/p/16856916.html