Tree add Render function

fixed #2133
fixed #1784
fixed #1333
fixed #1362
This commit is contained in:
梁灏 2017-10-24 16:20:09 +08:00
parent ecf6c2fae9
commit 9b24f1ab7b
2 changed files with 22 additions and 5 deletions

View file

@ -13,7 +13,6 @@
{
expand: true,
title: 'parent 1',
checked: true,
children: [
{
title: 'parent 1-0',
@ -26,16 +25,29 @@
},
{
title: 'leaf',
checked: false
}
]
},
{
title: 'parent 1-1',
expand: false,
expand: true,
checked: true,
children: [
{
title: '<span style="color: red">leaf</span>',
render: (h) => {
return h('Button', {
props: {
type: 'primary'
},
on: {
click: () => {
this.cc();
}
}
}, '我是按钮')
}
}
]
}
@ -54,7 +66,10 @@
)
},
handleUpdate () {
this.$set(this.baseData[0].children[0], 'disabled', false);
this.$set(this.baseData[0].children[0].children[1], 'checked', true);
},
cc () {
console.log(99)
}
}
}

View file

@ -11,7 +11,8 @@
:indeterminate="data.indeterminate"
:disabled="data.disabled || data.disableCheckbox"
@click.native.prevent="handleCheck"></Checkbox>
<span :class="titleClasses" v-html="data.title" @click="handleSelect"></span>
<Render v-if="data.render" :render="data.render"></Render>
<span v-else :class="titleClasses" v-html="data.title" @click="handleSelect"></span>
<Tree-node
v-if="data.expand"
v-for="item in data.children"
@ -27,6 +28,7 @@
<script>
import Checkbox from '../checkbox/checkbox.vue';
import Icon from '../icon/icon.vue';
import Render from '../base/render';
import CollapseTransition from '../base/collapse-transition';
import Emitter from '../../mixins/emitter';
@ -35,7 +37,7 @@
export default {
name: 'TreeNode',
mixins: [ Emitter ],
components: { Checkbox, Icon, CollapseTransition },
components: { Checkbox, Icon, CollapseTransition, Render },
props: {
data: {
type: Object,