Explorar o código

feat: 支持传入空数组

zhangweicheng %!s(int64=5) %!d(string=hai) anos
pai
achega
77028bda5f
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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] || [];
   }
 
   // 生成按照树结构排好序的数据