tree support accordion

This commit is contained in:
baiyaaaaa
2017-01-14 16:02:52 +08:00
committed by 杨奕
parent 39cbb051f1
commit 2072156e5b
6 changed files with 535 additions and 307 deletions

View File

@@ -35,7 +35,8 @@
:render-content="renderContent"
v-for="child in node.childNodes"
:key="getNodeKey(child)"
:node="child">
:node="child"
@click.native="handleChildNodeClick(child)">
</el-tree-node>
</div>
</collapse-transition>
@@ -45,10 +46,15 @@
<script type="text/jsx">
import CollapseTransition from 'element-ui/src/transitions/collapse-transition';
import ElCheckbox from 'element-ui/packages/checkbox';
import emitter from 'element-ui/src/mixins/emitter';
export default {
name: 'ElTreeNode',
componentName: 'ElTreeNode',
mixins: [emitter],
props: {
node: {
default() {
@@ -156,6 +162,10 @@
if (!this.node.indeterminate) {
this.node.setChecked(ev.target.checked, !this.tree.checkStrictly);
}
},
handleChildNodeClick(node) {
this.broadcast('ElTreeNode', 'tree-node-click', node);
}
},
@@ -186,6 +196,14 @@
this.expanded = true;
this.childNodeRendered = true;
}
if(this.tree.accordion) {
this.$on('tree-node-click', node => {
if(this.node !== node) {
this.node.collapse();
}
});
}
}
};
</script>