Function convertTreeData

  • 将树形数据转换为需要的格式

    Type Parameters

    • T extends Record<string, any>
    • P extends Record<string, any>

    Parameters

    • treeData: readonly T[]

      原始树形数据

    • callback: ((node: T, level: number) => P)
        • (node, level): P
        • Parameters

          • node: T
          • level: number

          Returns P

    • childrenFieldName: keyof T = 'children'
    • level: number = 0

    Returns ConvertedTreeData<T, P>[]

    树形数据结构