更新
addChild(data, parent)
在指定的父节点下添加子树。
参数
名称 | 类型 | 是否必选 | 描述 |
---|---|---|---|
data | object | true | 子树的数据 |
parent | Node | string | true |
用法
const data = {
id: 'sub1',
children: [
{
id: 'subTree1',
children: [...]
},
{
id: 'subTree2',
children: [...]
}
]
};
treeGraph.addChild(data, 'root')
updateChild(data, parent)
更新数据,差量更新子树。
参数
名称 | 类型 | 是否必选 | 描述 |
---|---|---|---|
data | object | true | 子树的数据 |
parent | Node | string | false |
⚠️注意:当parent参数为空时,则全量更新。
用法
const data = {
id: 'sub1',
children: [
{
id: 'subTree1',
children: [...]
},
{
id: 'subTree2',
children: [...]
}
]
};
treeGraph.updateChild(data, 'root')
removeChild(id)
删除指定的子树。
参数
名称 | 类型 | 是否必选 | 描述 |
---|---|---|---|
id | string | true | 要删除的子树的ID |
用法
treeGraph.removeChild('sub');