| | |
| | | console.log(selectedNodeId.value, "当前选中的节点"); |
| | | } |
| | | }; |
| | | const remove = (node: Node, data: Tree) => { |
| | | 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); |
| | | // menuOption.value = [...menuOption.value]; |
| | | }; |
| | | let id = 1000; |
| | | const append = (data: Tree) => { |
| | | const newChild = { id: id++, name: "testtest", children: [] }; |
| | | if (!data.children) { |
| | | data.children = []; |
| | | } |
| | | data.children.push(newChild); |
| | | // console.log(data); |
| | | // menuOption = [...menuOption]; |
| | | // console.log(menuOption); |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |