Tree/formatListToTree

list 数据结构 转换成 树结构
Source:
Example
formatListToTree({data: [{id:1}, {id: 2}, {id: 3, pid: 1}]})
=>
[ { id: 1, children: [ {id: 3, pid: 1} ] }, { id: 2 } ]
Parameters:
Name Type Description
data Array 需要转换的数据
id String 节点 id
pid String 父级节点 id
child String 子树为节点对象的某个属性值
labels Object 需要新增的字段名集合 { label: 'category_name' }
Returns:
Type
Array

Methods

(inner) insertNewKeys(labels, obj)

Source:
向原始对象中新增属性
Parameters:
Name Type Description
labels Object
obj Object