add node click event

This commit is contained in:
ayou
2018-02-11 21:35:53 +08:00
parent 1580a3524d
commit c846f7a9c1
4 changed files with 61 additions and 17 deletions

View File

@@ -15,7 +15,8 @@
@drop='drop'
@dragend='dragEnd'
@mouseover='mouseOver'
@mouseout='mouseOut'>
@mouseout='mouseOut'
@click.stop='click'>
<span class="caret icon is-small" v-if="model.children && model.children.length > 0">
<i class="vue-tree-icon" :class="caretClass" @click.prevent.stop="toggle"></i>
</span>
@@ -173,6 +174,15 @@
this.isHover = false
},
click() {
var node = this.$parent
var clickModel = this.model
while (node._props.model.name !== 'root') {
node = node.$parent
}
node.$emit('click', clickModel)
},
addChild(isLeaf) {
const name = isLeaf ? this.defaultLeafNodeName : this.defaultTreeNodeName
this.expanded = true