Tree add Render function
fixed #2133 fixed #1784 fixed #1333 fixed #1362
This commit is contained in:
parent
ecf6c2fae9
commit
9b24f1ab7b
2 changed files with 22 additions and 5 deletions
|
@ -13,7 +13,6 @@
|
||||||
{
|
{
|
||||||
expand: true,
|
expand: true,
|
||||||
title: 'parent 1',
|
title: 'parent 1',
|
||||||
checked: true,
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'parent 1-0',
|
title: 'parent 1-0',
|
||||||
|
@ -26,16 +25,29 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'leaf',
|
title: 'leaf',
|
||||||
|
checked: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'parent 1-1',
|
title: 'parent 1-1',
|
||||||
expand: false,
|
expand: true,
|
||||||
checked: true,
|
checked: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: '<span style="color: red">leaf</span>',
|
title: '<span style="color: red">leaf</span>',
|
||||||
|
render: (h) => {
|
||||||
|
return h('Button', {
|
||||||
|
props: {
|
||||||
|
type: 'primary'
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
click: () => {
|
||||||
|
this.cc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, '我是按钮')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -54,7 +66,10 @@
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
handleUpdate () {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
:indeterminate="data.indeterminate"
|
:indeterminate="data.indeterminate"
|
||||||
:disabled="data.disabled || data.disableCheckbox"
|
:disabled="data.disabled || data.disableCheckbox"
|
||||||
@click.native.prevent="handleCheck"></Checkbox>
|
@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
|
<Tree-node
|
||||||
v-if="data.expand"
|
v-if="data.expand"
|
||||||
v-for="item in data.children"
|
v-for="item in data.children"
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Checkbox from '../checkbox/checkbox.vue';
|
import Checkbox from '../checkbox/checkbox.vue';
|
||||||
import Icon from '../icon/icon.vue';
|
import Icon from '../icon/icon.vue';
|
||||||
|
import Render from '../base/render';
|
||||||
import CollapseTransition from '../base/collapse-transition';
|
import CollapseTransition from '../base/collapse-transition';
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@
|
||||||
export default {
|
export default {
|
||||||
name: 'TreeNode',
|
name: 'TreeNode',
|
||||||
mixins: [ Emitter ],
|
mixins: [ Emitter ],
|
||||||
components: { Checkbox, Icon, CollapseTransition },
|
components: { Checkbox, Icon, CollapseTransition, Render },
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue