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 | 13 | { |
14 | 14 | expand: true, |
15 | 15 | title: 'parent 1', |
16 | - checked: true, | |
17 | 16 | children: [ |
18 | 17 | { |
19 | 18 | title: 'parent 1-0', |
... | ... | @@ -26,16 +25,29 @@ |
26 | 25 | }, |
27 | 26 | { |
28 | 27 | title: 'leaf', |
28 | + checked: false | |
29 | 29 | } |
30 | 30 | ] |
31 | 31 | }, |
32 | 32 | { |
33 | 33 | title: 'parent 1-1', |
34 | - expand: false, | |
34 | + expand: true, | |
35 | 35 | checked: true, |
36 | 36 | children: [ |
37 | 37 | { |
38 | 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 | 66 | ) |
55 | 67 | }, |
56 | 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 | 11 | :indeterminate="data.indeterminate" |
12 | 12 | :disabled="data.disabled || data.disableCheckbox" |
13 | 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 | 16 | <Tree-node |
16 | 17 | v-if="data.expand" |
17 | 18 | v-for="item in data.children" |
... | ... | @@ -27,6 +28,7 @@ |
27 | 28 | <script> |
28 | 29 | import Checkbox from '../checkbox/checkbox.vue'; |
29 | 30 | import Icon from '../icon/icon.vue'; |
31 | + import Render from '../base/render'; | |
30 | 32 | import CollapseTransition from '../base/collapse-transition'; |
31 | 33 | import Emitter from '../../mixins/emitter'; |
32 | 34 | |
... | ... | @@ -35,7 +37,7 @@ |
35 | 37 | export default { |
36 | 38 | name: 'TreeNode', |
37 | 39 | mixins: [ Emitter ], |
38 | - components: { Checkbox, Icon, CollapseTransition }, | |
40 | + components: { Checkbox, Icon, CollapseTransition, Render }, | |
39 | 41 | props: { |
40 | 42 | data: { |
41 | 43 | type: Object, | ... | ... |