Browse Source

feat: 支持传入空数组

zhangweicheng 5 năm trước cách đây
mục cha
commit
77028bda5f
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      tree/src/index.ts

+ 1 - 1
tree/src/index.ts

@@ -96,7 +96,7 @@ export class Tree {
 
   // 获取顶层原始数据
   getRoots(): TreeNode[] {
-    return this.parentMap[this.rootID];
+    return this.parentMap[this.rootID] || [];
   }
 
   // 生成按照树结构排好序的数据