Commit 1183836a92ddebd53d92d027abb1afacd07185c2
1 parent
f3893b00
update
Showing
1 changed file
with
30 additions
and
31 deletions
Show diff stats
examples/routers/tree.vue
| 1 | 1 | <template> |
| 2 | - <Tree :data="baseData" show-checkbox @on-check-change="handleChange" @on-toggle-expand="showExpand"></Tree> | |
| 2 | + <Tree :data="db" show-checkbox></Tree> | |
| 3 | 3 | </template> |
| 4 | 4 | <script> |
| 5 | 5 | export default { |
| 6 | 6 | data () { |
| 7 | 7 | return { |
| 8 | - bd: [], | |
| 9 | - baseData: [ | |
| 8 | + db:[ | |
| 10 | 9 | { |
| 11 | - title: 'parent', | |
| 12 | - id: '1-0', | |
| 13 | - expand: true, | |
| 10 | + title: '父级', | |
| 11 | + checked: false, | |
| 14 | 12 | children: [ |
| 15 | 13 | { |
| 16 | - title: 'child1', | |
| 17 | - id: '1-1', | |
| 18 | - expand: true, | |
| 14 | + title: '孩子', | |
| 15 | + checked: false, | |
| 19 | 16 | children: [ |
| 20 | 17 | { |
| 21 | - title: 'child1-1-1', | |
| 22 | - id: '1-1-1' | |
| 18 | + title: '孙子', | |
| 19 | + checked: true | |
| 23 | 20 | }, |
| 24 | 21 | { |
| 25 | - title: 'child1-1-2', | |
| 26 | - id: '1-1-2' | |
| 22 | + title: '孙子', | |
| 23 | + checked: false, | |
| 24 | + children: [ | |
| 25 | + { | |
| 26 | + title: '曾孙', | |
| 27 | + checked: false | |
| 28 | + } | |
| 29 | + ] | |
| 27 | 30 | } |
| 28 | 31 | ] |
| 32 | + } | |
| 33 | + ] | |
| 34 | + }, | |
| 35 | + { | |
| 36 | + title: '其他', | |
| 37 | + checked: false, | |
| 38 | + children: [ | |
| 39 | + { | |
| 40 | + title: '其他孩子', | |
| 41 | + checked: true | |
| 29 | 42 | }, |
| 30 | 43 | { |
| 31 | - title: 'child2', | |
| 32 | - id: '1-2', | |
| 33 | - children: [] | |
| 44 | + title: '其他孩子2', | |
| 45 | + checked: true | |
| 34 | 46 | } |
| 35 | 47 | ] |
| 36 | 48 | } |
| ... | ... | @@ -38,23 +50,10 @@ |
| 38 | 50 | } |
| 39 | 51 | }, |
| 40 | 52 | methods: { |
| 41 | - handleSelectChange (data) { | |
| 42 | - console.log(data); | |
| 43 | - }, | |
| 44 | - updateTree (data) { | |
| 45 | - data[0].children[0].checked = true; | |
| 46 | -// data[0].children[0].children[0].checked = true; | |
| 47 | -// data[0].children[0].children[1].checked = true; | |
| 48 | - }, | |
| 49 | - handleChange () { | |
| 50 | - console.log(1) | |
| 51 | - }, | |
| 52 | - showExpand (payload) { | |
| 53 | - console.log(payload) | |
| 54 | - } | |
| 53 | + | |
| 55 | 54 | }, |
| 56 | 55 | mounted () { |
| 57 | - this.updateTree(this.baseData); | |
| 56 | + | |
| 58 | 57 | } |
| 59 | 58 | } |
| 60 | 59 | </script> | ... | ... |