Merge pull request #801 from lcx960324/2.0
new feature: @on-toggle-expand on Tree
This commit is contained in:
commit
f363071873
3 changed files with 8 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Tree :data="baseData" show-checkbox @on-check-change="handleChange" ></Tree>
|
<Tree :data="baseData" show-checkbox @on-check-change="handleChange" @on-toggle-expand="showExpand"></Tree>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
@ -47,6 +47,9 @@
|
||||||
},
|
},
|
||||||
handleChange () {
|
handleChange () {
|
||||||
console.log(1)
|
console.log(1)
|
||||||
|
},
|
||||||
|
showExpand (payload) {
|
||||||
|
console.log(payload)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
handleExpand () {
|
handleExpand () {
|
||||||
if (this.data.disabled) return;
|
if (this.data.disabled) return;
|
||||||
this.$set(this.data, 'expand', !this.data.expand);
|
this.$set(this.data, 'expand', !this.data.expand);
|
||||||
|
this.dispatch('Tree', 'toggle-expand', this.data);
|
||||||
},
|
},
|
||||||
handleSelect () {
|
handleSelect () {
|
||||||
if (this.data.disabled) return;
|
if (this.data.disabled) return;
|
||||||
|
|
|
@ -102,7 +102,6 @@
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.updateData();
|
this.updateData();
|
||||||
|
|
||||||
this.$on('selected', ori => {
|
this.$on('selected', ori => {
|
||||||
const nodes = findComponentsDownward(this, 'TreeNode');
|
const nodes = findComponentsDownward(this, 'TreeNode');
|
||||||
nodes.forEach(node => {
|
nodes.forEach(node => {
|
||||||
|
@ -119,6 +118,9 @@
|
||||||
this.$on('on-checked', () => {
|
this.$on('on-checked', () => {
|
||||||
this.$emit('on-check-change', this.getCheckedNodes());
|
this.$emit('on-check-change', this.getCheckedNodes());
|
||||||
});
|
});
|
||||||
|
this.$on('toggle-expand', (payload) => {
|
||||||
|
this.$emit('on-toggle-expand', payload);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
data () {
|
data () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue