瀏覽代碼

feat(tree): 获取最后子节点序列号

zhangweicheng 5 年之前
父節點
當前提交
05f533664c
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. 1 1
      tree/package.json
  2. 6 0
      tree/src/nodeCtx.ts

+ 1 - 1
tree/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/tree",
-  "version": "1.0.14",
+  "version": "1.0.15",
   "description": "通用树",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",

+ 6 - 0
tree/src/nodeCtx.ts

@@ -93,6 +93,12 @@ export class NodeContext<T = any> {
     return children[children.length - 1] || null;
   }
 
+  latestChildSeq(): number {
+    const latestChild = this.lastChild();
+    if (latestChild) return latestChild.seq;
+    return 0;
+  }
+
   // 获取节点后代(包含嵌套子项)
   posterity(): (TreeNode & T)[] {
     const posterity: (TreeNode & T)[] = [];