Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "tree"

Index

Type aliases

EachTreeCallback

EachTreeCallback<T>: (...args: EachTreeCallbackArguments<T>) => boolean | void

递归回调

Type parameters

  • T

Type declaration

EachTreeCallbackArguments

EachTreeCallbackArguments<T>: [TreeData, number, T[], T]

递归回调参数列表

Type parameters

  • T

IDKey

IDKey: string | number

ToRowsCustomizer

ToRowsCustomizer<T, R>: (...args: EachTreeCallbackArguments<T>) => R

树形数据转行数据的自定义转换函数

Type parameters

Type declaration

TreeData

TreeData: Record<string | symbol | number, unknown>

Functions

eachTree

  • eachTree<T, K>(data: T[], childrenKey: K, callback: EachTreeCallback<T>): void
  • 遍历树形数据节点

    Type parameters

    Parameters

    • data: T[]

      树形数据

    • childrenKey: K

      子节点的 key

    • callback: EachTreeCallback<T>

      回调函数

    Returns void

toTree

  • toTree(data: Record<string, any>[], options?: Partial<TreeOptions>): any[]
  • 行转树型数据

    throws

    非数组就报异常

    example

    rowToTree([ {id: 0, parentId: null, name: 'level 1'}, {id: 1, parentId: 0, name: 'level 1-1'}, {id: 2, parentId: 0, name: 'level 1-2'} ])

    Parameters

    • data: Record<string, any>[]
    • Default value options: Partial<TreeOptions> = {}

      可选配置

    Returns any[]

    树型数据

treeToRows

  • treeToRows<T, R>(data: T[]): R[]
  • treeToRows<T, R>(data: T[], childrenKey: string): R[]
  • treeToRows<T, R>(data: T[], customizer: ToRowsCustomizer<T, R>): R[]
  • treeToRows<T, R>(data: T[], childrenKey: string, customizer: ToRowsCustomizer<T, R>): R[]

Generated using TypeDoc