Commit f363071873c408368e2cd6afc784c3950f963081
Committed by
GitHub
Merge pull request #801 from lcx960324/2.0
new feature: @on-toggle-expand on Tree
Showing
3 changed files
with
8 additions
and
2 deletions
Show diff stats
examples/routers/tree.vue
| 1 | 1 | <template> |
| 2 | - <Tree :data="baseData" show-checkbox @on-check-change="handleChange" ></Tree> | |
| 2 | + <Tree :data="baseData" show-checkbox @on-check-change="handleChange" @on-toggle-expand="showExpand"></Tree> | |
| 3 | 3 | </template> |
| 4 | 4 | <script> |
| 5 | 5 | export default { |
| ... | ... | @@ -47,6 +47,9 @@ |
| 47 | 47 | }, |
| 48 | 48 | handleChange () { |
| 49 | 49 | console.log(1) |
| 50 | + }, | |
| 51 | + showExpand (payload) { | |
| 52 | + console.log(payload) | |
| 50 | 53 | } |
| 51 | 54 | }, |
| 52 | 55 | mounted () { | ... | ... |
src/components/tree/node.vue
src/components/tree/tree.vue
| ... | ... | @@ -102,7 +102,6 @@ |
| 102 | 102 | }, |
| 103 | 103 | mounted () { |
| 104 | 104 | this.updateData(); |
| 105 | - | |
| 106 | 105 | this.$on('selected', ori => { |
| 107 | 106 | const nodes = findComponentsDownward(this, 'TreeNode'); |
| 108 | 107 | nodes.forEach(node => { |
| ... | ... | @@ -119,6 +118,9 @@ |
| 119 | 118 | this.$on('on-checked', () => { |
| 120 | 119 | this.$emit('on-check-change', this.getCheckedNodes()); |
| 121 | 120 | }); |
| 121 | + this.$on('toggle-expand', (payload) => { | |
| 122 | + this.$emit('on-toggle-expand', payload); | |
| 123 | + }); | |
| 122 | 124 | }, |
| 123 | 125 | watch: { |
| 124 | 126 | data () { | ... | ... |