Skip to content

Variables

findTree

const findTree: FindTreeFunc

根据迭代器查找树列表子节点

Param

树列表

Param

迭代器

Param

配置项

Example

ts
findTree(
  [
    {
      id: 1,
      text: '1',
      children: [
        {
          id: 3,
          text: '3',
        }
      ]
    },
    {
      id: 2,
      text: '2',
    }
  ],
  (node) => node.id >= 2,
)
// => { index: 0, node: { id: 3, text: '3', }, paths: ['0', 'children', '0'], nodes: [{ id: 1, text: '1', children: [{...}], }, { id: 3, text: '3', }], tree: [...] }

Interfaces

FindResult<T>

Type Parameters

Type Parameter
T

Properties

PropertyType
indexnumber
nodeT
nodesT[]
parent?T
pathsstring[]
treeT[]

FindTreeOptions

Properties

PropertyTypeDescription
childrenKey?string子节点键 Default 'children'