Skip to content

eachTree

Functions

eachTree()

eachTree<T>(array, iterator, options): any

根据迭代器遍历树列表

Type parameters

Parameter
T extends Object

Parameters

ParameterTypeDescription
arrayT[]树列表
iteratorTreeIterator<T, void>迭代器
optionsEachTreeOptions配置项

Returns

any

Example

ts
eachTree(
  [
    {
      id: 1,
      text: '1',
      children: [
        {
          id: 3,
          text: '3',
        }
      ]
    },
    {
      id: 2,
      text: '2',
    }
  ],
  (node) => console.log(node.text),
)

Interfaces

EachTreeOptions

Properties

PropertyTypeDescription
childrenKey?string子节点键

Default
'children'