findTree
Functions
findTree()
findTree<
T
>(array
,iterator
,options
?):undefined
|FindResult
<T
>
根据迭代器查找树列表子节点
Type parameters
Parameter |
---|
T extends Object |
Parameters
Parameter | Type | Description |
---|---|---|
array | T [] | 树列表 |
iterator | TreeIterator <T , boolean > | 迭代器 |
options ? | FindTreeOptions | 配置项 |
Returns
undefined
| FindResult
<T
>
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
Parameter |
---|
T |
Properties
Property | Type | Description |
---|---|---|
index | number | - |
node | T | - |
nodes | T [] | - |
parent? | T | - |
paths | string [] | - |
tree | T [] | - |
FindTreeOptions
Properties
Property | Type | Description |
---|---|---|
childrenKey? | string | 子节点键 Default 'children' |