Skip to content

Commit

Permalink
update expand handler
Browse files Browse the repository at this point in the history
  • Loading branch information
hukaibaihu committed Jun 6, 2020
1 parent bbaaa8c commit ee9ec85
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
<div>
<vue2-org-tree
:data="tree"
collapsable
:label-width="90"
:label-class-name="labelClass"
:render-content="renderContent"
@on-expand="onExpand"
@on-node-click="onNodeClick"
@on-node-mouseover="onNodeMouseOver"
@on-node-mouseout="onNodeMouseOut"
Expand Down Expand Up @@ -46,6 +48,25 @@
renderContent (h, data) {
return data.label;
},
onExpand (e, data) {
if ('expand' in data) {
data.expand = !data.expand
if (!data.expand && data.children) {
this.collapse(data.children)
}
} else {
this.$set(data, 'expand', true)
}
},
collapse (nodes) {
nodes.forEach(node => {
if (node.expand) {
node.expand = false
}

node.children && this.collapse(node.children)
})
},
onNodeClick (e, data) {
console.log('CLICK', e);
},
Expand Down

0 comments on commit ee9ec85

Please sign in to comment.