convertToTree(data, pid = null) {
const children = data.filter(node => node.pid === pid);
if (!children.length) {
return null;
}
return children.map(node => ({
...node,
children: this.convertToTree(data, node.id)
}));
},
数据扁平化转为树形结构
于 2023-04-13 14:06:07 首次发布