Variables
searchTree
const
searchTree:SearchTreeFunc
根据迭代器搜索树列表的子项数据,区别于 filterTree
会返回完整的树形结构列表
注意:当父级符合搜索规则时将保留所有子级数据!
Param
树列表
Param
迭代器
Param
配置项
Example
ts
searchTree(
[
{
id: 1,
text: '1',
children: [
{
id: 3,
text: '3',
}
]
},
{
id: 2,
text: '2',
}
],
(node) => node.id === 3,
)
// => [{ id: 1, text: '1', children: [{ id: 3, text: '3', }] }]
Interfaces
SearchTreeOptions<ChildrenKey, MappingChildrenKey>
Type Parameters
Type Parameter | Default type |
---|---|
ChildrenKey extends string | string |
MappingChildrenKey extends string | never |