Tree: add expand-on-click-node prop. (#1805)

This commit is contained in:
FuryBean
2016-12-19 15:38:51 +08:00
committed by cinwell.li
parent 1ba0745f00
commit 40f9d83f87
5 changed files with 25 additions and 9 deletions

View File

@@ -8,10 +8,10 @@
'is-hidden': !node.visible
}">
<div class="el-tree-node__content"
:style="{ 'padding-left': (node.level - 1) * 16 + 'px' }"
@click="handleExpandIconClick">
:style="{ 'padding-left': (node.level - 1) * 16 + 'px' }">
<span
class="el-tree-node__expand-icon"
@click.stop="handleExpandIconClick"
:class="{ 'is-leaf': node.isLeaf, expanded: !node.isLeaf && expanded }">
</span>
<el-checkbox
@@ -131,19 +131,19 @@
const store = this.tree.store;
store.setCurrentNode(this.node);
this.tree.$emit('current-change', store.currentNode ? store.currentNode.data : null, store.currentNode);
this.tree.currentNode = this;
if (this.tree.expandOnClickNode) {
this.handleExpandIconClick(event);
}
this.tree.$emit('node-click', this.node.data, this.node, this);
},
handleExpandIconClick(event) {
let target = event.target;
if (target.tagName.toUpperCase() !== 'DIV' &&
target.parentNode.nodeName.toUpperCase() !== 'DIV' ||
target.nodeName.toUpperCase() === 'LABEL') return;
if (this.expanded) {
this.node.collapse();
} else {
this.node.expand();
}
this.tree.$emit('node-click', this.node.data, this.node, this);
},
handleUserClick() {