diff --git a/examples/routers/tree.vue b/examples/routers/tree.vue index 55cff15..068541f 100644 --- a/examples/routers/tree.vue +++ b/examples/routers/tree.vue @@ -1,135 +1,94 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/tree/node.vue b/src/components/tree/node.vue index 6935dcb..f7b6de9 100644 --- a/src/components/tree/node.vue +++ b/src/components/tree/node.vue @@ -12,8 +12,9 @@ :indeterminate="data.indeterminate" :disabled="data.disabled || data.disableCheckbox" @click.native.prevent="handleCheck"> - - + + + {{ data.title }} import Checkbox from '../checkbox/checkbox.vue'; import Icon from '../icon/icon.vue'; - import Render from '../base/render'; + import Render from './render'; import CollapseTransition from '../base/collapse-transition'; import Emitter from '../../mixins/emitter'; import { findComponentUpward } from '../../utils/assist'; @@ -61,9 +62,6 @@ prefixCls: prefixCls }; }, - watch: { - - }, computed: { classes () { return [ @@ -99,6 +97,18 @@ }, showLoading () { return 'loading' in this.data && this.data.loading; + }, + isParentRender () { + const Tree = findComponentUpward(this, 'Tree'); + return Tree && Tree.render; + }, + parentRender () { + const Tree = findComponentUpward(this, 'Tree'); + if (Tree && Tree.render) { + return Tree.render; + } else { + return null; + } } }, methods: { diff --git a/src/components/tree/render.js b/src/components/tree/render.js new file mode 100644 index 0000000..ce66f3a --- /dev/null +++ b/src/components/tree/render.js @@ -0,0 +1,14 @@ +export default { + name: 'RenderCell', + functional: true, + props: { + render: Function, + node: Object + }, + render: (h, ctx) => { + const params = { + node: ctx.props.node + }; + return ctx.props.render(h, params); + } +}; \ No newline at end of file diff --git a/src/components/tree/tree.vue b/src/components/tree/tree.vue index 603885f..bf3d360 100644 --- a/src/components/tree/tree.vue +++ b/src/components/tree/tree.vue @@ -42,6 +42,9 @@ }, loadData: { type: Function + }, + render: { + type: Function } }, data () { -- libgit2 0.21.4