Commit e6b89257 authored by baiyaaaaa's avatar baiyaaaaa Committed by cinwell.li

fix tree accordion bug when click on icon (#2440)

parent d973911b
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
v-for="child in node.childNodes" v-for="child in node.childNodes"
:key="getNodeKey(child)" :key="getNodeKey(child)"
:node="child" :node="child"
@click.native="handleChildNodeClick(child)"> @node-expand="handleChildNodeExpand(child)">
</el-tree-node> </el-tree-node>
</div> </div>
</collapse-transition> </collapse-transition>
...@@ -149,6 +149,7 @@ ...@@ -149,6 +149,7 @@
this.node.collapse(); this.node.collapse();
} else { } else {
this.node.expand(); this.node.expand();
this.$emit('node-expand', this.node.data, this.node, this);
} }
}, },
...@@ -164,8 +165,8 @@ ...@@ -164,8 +165,8 @@
} }
}, },
handleChildNodeClick(node) { handleChildNodeExpand(node) {
this.broadcast('ElTreeNode', 'tree-node-click', node); this.broadcast('ElTreeNode', 'tree-node-expand', node);
} }
}, },
...@@ -198,7 +199,7 @@ ...@@ -198,7 +199,7 @@
} }
if(this.tree.accordion) { if(this.tree.accordion) {
this.$on('tree-node-click', node => { this.$on('tree-node-expand', node => {
if(this.node !== node) { if(this.node !== node) {
this.node.collapse(); this.node.collapse();
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
:props="props" :props="props"
:key="getNodeKey(child)" :key="getNodeKey(child)"
:render-content="renderContent" :render-content="renderContent"
@click.native="handleChildNodeClick(child)"> @node-expand="handleNodeExpand">
</el-tree-node> </el-tree-node>
<div class="el-tree__empty-block" v-if="!root.childNodes || root.childNodes.length === 0"> <div class="el-tree__empty-block" v-if="!root.childNodes || root.childNodes.length === 0">
<span class="el-tree__empty-text">{{ emptyText }}</span> <span class="el-tree__empty-text">{{ emptyText }}</span>
...@@ -141,8 +141,8 @@ ...@@ -141,8 +141,8 @@
setChecked(data, checked, deep) { setChecked(data, checked, deep) {
this.store.setChecked(data, checked, deep); this.store.setChecked(data, checked, deep);
}, },
handleChildNodeClick(node) { handleNodeExpand(nodeData, node, instance) {
this.broadcast('ElTreeNode', 'tree-node-click', node); this.broadcast('ElTreeNode', 'tree-node-expand', node);
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment