function treeToArray(tree: any = [], result = []) {
for (const item of tree) {
result.push(item);
if (item.children) {
treeToArray(item.children, result);
Reflect.deleteProperty(item, 'children');
}
}
return result.sort((a: any, b: any) => a.id - b.id);
// return result;
}
js树到数组
最新推荐文章于 2024-06-13 16:05:36 发布