@@ -29,32 +29,32 @@ import 'vue3-tree-vue/dist/style.css'; // remember to add this in your component
29
29
setup () {
30
30
const onItemChecked = (checkedItems : TreeViewItem []) => console .log (checkedItems );
31
31
const onItemSelected = (item : TreeViewItem ) => console .log (item );
32
-
32
+
33
33
// How to handle drag and drop logic
34
34
const onBeforeItemDropped = (droppedItem : TreeViewItem , destinationNode : TreeViewItem | undefined ) => {
35
- // destinationNode == undefined means dropping at the root of the tree.
36
-
37
- // Here you can specify any kind of drop validation you will like.
38
- // this function should return true if the drop operation is valid.
39
-
40
- return new Promise ((resolve , _ ) => {
41
- resolve (droppedItem !== destinationNode ) // Replace this logic with your logic.
42
- });
35
+ // destinationNode == undefined means dropping at the root of the tree.
36
+
37
+ // Here you can specify any kind of drop validation you will like.
38
+ // this function should return true if the drop operation is valid.
39
+
40
+ return new Promise ((resolve , _ ) => {
41
+ resolve (droppedItem !== destinationNode ) // Replace this logic with your logic.
42
+ });
43
43
}
44
44
const onItemExpanded = (expandedItem : TreeViewItem ) => {
45
- // to use this feature properly you need to set lazyLoad property as true
46
- // fetch data
47
- const lazyLoadedItems = fetchFromApi (... );
48
- expandedItem .children .push (... lazyLoadedItems )
45
+ // to use this feature properly you need to set lazyLoad property as true
46
+ // fetch data
47
+ const lazyLoadedItems = fetchFromApi (... );
48
+ expandedItem .children .push (... lazyLoadedItems )
49
49
}
50
50
const items = ref <TreeViewItem []>([]); // define your tree items here.
51
51
52
52
return {
53
- onItemChecked ,
54
- onItemSelected ,
55
- onBeforeItemDropped ,
56
- onItemExpanded ,
57
- items
53
+ onItemChecked ,
54
+ onItemSelected ,
55
+ onBeforeItemDropped ,
56
+ onItemExpanded ,
57
+ items
58
58
}
59
59
}
60
60
```
@@ -125,4 +125,4 @@ export interface TreeViewItem {
125
125
126
126
| Name | Description |
127
127
| -------------|-------------
128
- | on-item-hover | Use in ` child-append ` and ` item-append ` slots to only show when the cursor is hovering on the node
128
+ | on-item-hover | Use in ` child-append ` and ` item-append ` slots to only show when the cursor is hovering on the node
0 commit comments