Browse Source

feat: 支持传入空数组

zhangweicheng 5 years ago
parent
commit
77028bda5f
1 changed files with 1 additions and 1 deletions
  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] || [];
   }
 
   // 生成按照树结构排好序的数据