Tree/formatTree

list 数据结构 转换成 树结构
Source:
Example
formatTree([{id:1, pid: 0}, {id: 2, pid: 0}, {id: 3, pid: 1}])
=>
[ { id: 1, pid: 0 children: [ {id: 3, pid: 1} ] }, { id: 2, pid: 0 } ]
Parameters:
Name Type Description
data Array 需要转换的数据
options object 配置信息
id String 节点 id
pid String 父级节点 id
children String 子树为节点对象的某个属性值
root String | number 指定根节点 value
Returns:
Type
Array