diff --git a/docs/examples/tree/customized-node.vue b/docs/examples/tree/customized-node.vue
index 42face1cc4..21ff811563 100644
--- a/docs/examples/tree/customized-node.vue
+++ b/docs/examples/tree/customized-node.vue
@@ -2,6 +2,7 @@
Using render-content
Using scoped slot
()
+const treeRef2 = ref()
const append = (data: Data) => {
const newChild = { id: id++, label: 'testtest', children: [] }
- if (!data.children) {
- data.children = []
- }
- data.children.push(newChild)
- dataSource.value = [...dataSource.value]
+ treeRef1.value?.append(newChild, data)
+ treeRef2.value?.append(newChild, data)
}
const remove = (node: Node, data: Data) => {
- const parent = node.parent
- const children: Tree[] = parent?.data.children || parent?.data
- const index = children.findIndex((d) => d.id === data.id)
- children.splice(index, 1)
- dataSource.value = [...dataSource.value]
+ treeRef1.value?.remove(data)
+ treeRef2.value?.remove(data)
}
const renderContent: RenderContentFunction = (h, { node, data }) => {