Skip to content

Home > @jview/utils > getTreeNodeByKey

getTreeNodeByKey() function

根据目标 key 值找到

Signature:

typescript
export declare function getTreeNodeByKey<K extends string = 'key', C extends string = 'children', T extends TreeNode<K, C> = TreeNode<K, C>>(nodes: T[], key: string | number, mapper: FieldMapper<K, C>): T | null;
export declare function getTreeNodeByKey<K extends string = 'key', C extends string = 'children', T extends TreeNode<K, C> = TreeNode<K, C>>(nodes: T[], key: string | number, mapper: FieldMapper<K, C>): T | null;

Parameters

ParameterTypeDescription
nodesT[]节点数组
keystring | number目标 key 值
mapperFieldMapper<K, C>字段映射,主要是映射 key 和 children 字段

Returns:

T | null