mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-19 12:04:02 +08:00
tree support accordion
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user