Emits
You can access up-to-date data in the operations you perform for the tree with the emit
's we use in the package.
nodeClick
This emit is triggered when a node is clicked or selected.
Usage
<Tree :nodes="data" @nodeClick="onNodeClick" />
1
const onNodeClick = (node) => {
console.log(node);
};
1
2
3
2
3
nodeExpanded
When you click on an item, you can use the emit "nodeExpanded" if you want to see the current values of that item and the data below it. This way you will only be able to access the data for that item.
Usage
<Tree :nodes="data" @nodeExpanded="onNodeExpanded" />
1
const onNodeExpanded = (node, state) => {
console.log('node: ', node);
console.log('state: ', state);
};
1
2
3
4
2
3
4
update:nodes
Returns the current data of the tree when a data is deleted or a checkbox is clicked in the tree. If you are considering to use @update:nodes
for only updating data, you can also use v-model:nodes
Usage
<Tree :nodes="data" @update:nodes="onUpdate" />
1
const onUpdate = (nodes) => {
console.log('nodes: ', nodes);
};
1
2
3
2
3