Commit 9b24f1ab7b4455d9af92960708c7d3b5e80110b2
1 parent
ecf6c2fa
Tree add Render function
fixed #2133 fixed #1784 fixed #1333 fixed #1362
Showing
2 changed files
with
22 additions
and
5 deletions
Show diff stats
examples/routers/tree.vue
| @@ -13,7 +13,6 @@ | @@ -13,7 +13,6 @@ | ||
| 13 | { | 13 | { |
| 14 | expand: true, | 14 | expand: true, |
| 15 | title: 'parent 1', | 15 | title: 'parent 1', |
| 16 | - checked: true, | ||
| 17 | children: [ | 16 | children: [ |
| 18 | { | 17 | { |
| 19 | title: 'parent 1-0', | 18 | title: 'parent 1-0', |
| @@ -26,16 +25,29 @@ | @@ -26,16 +25,29 @@ | ||
| 26 | }, | 25 | }, |
| 27 | { | 26 | { |
| 28 | title: 'leaf', | 27 | title: 'leaf', |
| 28 | + checked: false | ||
| 29 | } | 29 | } |
| 30 | ] | 30 | ] |
| 31 | }, | 31 | }, |
| 32 | { | 32 | { |
| 33 | title: 'parent 1-1', | 33 | title: 'parent 1-1', |
| 34 | - expand: false, | 34 | + expand: true, |
| 35 | checked: true, | 35 | checked: true, |
| 36 | children: [ | 36 | children: [ |
| 37 | { | 37 | { |
| 38 | title: '<span style="color: red">leaf</span>', | 38 | title: '<span style="color: red">leaf</span>', |
| 39 | + render: (h) => { | ||
| 40 | + return h('Button', { | ||
| 41 | + props: { | ||
| 42 | + type: 'primary' | ||
| 43 | + }, | ||
| 44 | + on: { | ||
| 45 | + click: () => { | ||
| 46 | + this.cc(); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + }, '我是按钮') | ||
| 50 | + } | ||
| 39 | } | 51 | } |
| 40 | ] | 52 | ] |
| 41 | } | 53 | } |
| @@ -54,7 +66,10 @@ | @@ -54,7 +66,10 @@ | ||
| 54 | ) | 66 | ) |
| 55 | }, | 67 | }, |
| 56 | handleUpdate () { | 68 | handleUpdate () { |
| 57 | - this.$set(this.baseData[0].children[0], 'disabled', false); | 69 | + this.$set(this.baseData[0].children[0].children[1], 'checked', true); |
| 70 | + }, | ||
| 71 | + cc () { | ||
| 72 | + console.log(99) | ||
| 58 | } | 73 | } |
| 59 | } | 74 | } |
| 60 | } | 75 | } |
src/components/tree/node.vue
| @@ -11,7 +11,8 @@ | @@ -11,7 +11,8 @@ | ||
| 11 | :indeterminate="data.indeterminate" | 11 | :indeterminate="data.indeterminate" |
| 12 | :disabled="data.disabled || data.disableCheckbox" | 12 | :disabled="data.disabled || data.disableCheckbox" |
| 13 | @click.native.prevent="handleCheck"></Checkbox> | 13 | @click.native.prevent="handleCheck"></Checkbox> |
| 14 | - <span :class="titleClasses" v-html="data.title" @click="handleSelect"></span> | 14 | + <Render v-if="data.render" :render="data.render"></Render> |
| 15 | + <span v-else :class="titleClasses" v-html="data.title" @click="handleSelect"></span> | ||
| 15 | <Tree-node | 16 | <Tree-node |
| 16 | v-if="data.expand" | 17 | v-if="data.expand" |
| 17 | v-for="item in data.children" | 18 | v-for="item in data.children" |
| @@ -27,6 +28,7 @@ | @@ -27,6 +28,7 @@ | ||
| 27 | <script> | 28 | <script> |
| 28 | import Checkbox from '../checkbox/checkbox.vue'; | 29 | import Checkbox from '../checkbox/checkbox.vue'; |
| 29 | import Icon from '../icon/icon.vue'; | 30 | import Icon from '../icon/icon.vue'; |
| 31 | + import Render from '../base/render'; | ||
| 30 | import CollapseTransition from '../base/collapse-transition'; | 32 | import CollapseTransition from '../base/collapse-transition'; |
| 31 | import Emitter from '../../mixins/emitter'; | 33 | import Emitter from '../../mixins/emitter'; |
| 32 | 34 | ||
| @@ -35,7 +37,7 @@ | @@ -35,7 +37,7 @@ | ||
| 35 | export default { | 37 | export default { |
| 36 | name: 'TreeNode', | 38 | name: 'TreeNode', |
| 37 | mixins: [ Emitter ], | 39 | mixins: [ Emitter ], |
| 38 | - components: { Checkbox, Icon, CollapseTransition }, | 40 | + components: { Checkbox, Icon, CollapseTransition, Render }, |
| 39 | props: { | 41 | props: { |
| 40 | data: { | 42 | data: { |
| 41 | type: Object, | 43 | type: Object, |