@supuwoerc/toolkit
    Preparing search index...

    Function getParents

    • 获取目标节点所有父节点(从根到目标的路径)

      Get all parent nodes of a target (path from root to target).

      Type Parameters

      • T = Partial<TreeNode>

        节点类型 / node type

      Parameters

      • tree: T[]

        树数组 / tree array

      • target: any

        目标值,用于与节点 id 进行比较 / target value to compare with node id

      • OptionalidKey: keyof T = ...

        表示节点 id 的字段名 / field name for node id (default: 'id')

      • OptionalchildrenKey: keyof T = ...

        子节点字段名 / children field name (default: 'children')

      • OptionalequalFunc: EqualFunc<any> = ...

        自定义相等比较函数 / custom equality function (default: (val, tarVal) => val === tarVal)

      Returns T[]

      从根到目标的节点数组(包含目标节点)/ array of nodes from root to target (includes target)

      // getParents(tree, 5)