diff --git a/components/vc-tree/NodeList.tsx b/components/vc-tree/NodeList.tsx index 1ef1a433b..6dbe01dd8 100644 --- a/components/vc-tree/NodeList.tsx +++ b/components/vc-tree/NodeList.tsx @@ -94,8 +94,7 @@ export default defineComponent({ name: 'NodeList', inheritAttrs: false, props: nodeListProps, - slots: ['checkable'], - setup(props, { expose, attrs, slots }) { + setup(props, { expose, attrs }) { // =============================== Ref ================================ const listRef = ref(null); const indentMeasurerRef = ref(null); @@ -310,7 +309,6 @@ export default defineComponent({ onMousemove={() => { onActiveChange(null); }} - v-slots={slots} /> ); }} diff --git a/components/vc-tree/Tree.tsx b/components/vc-tree/Tree.tsx index 3f71b860c..e6a7b023f 100644 --- a/components/vc-tree/Tree.tsx +++ b/components/vc-tree/Tree.tsx @@ -34,7 +34,7 @@ import classNames from '../_util/classNames'; export default defineComponent({ name: 'Tree', inheritAttrs: false, - slots: ['checkable'], + slots: ['checkable', 'title', 'icon'], props: initDefaultProps(treeProps(), { prefixCls: 'vc-tree', showLine: false, @@ -982,7 +982,7 @@ export default defineComponent({ tabindex = 0, selectable, showIcon, - icon, + icon = slots.icon, switcherIcon, draggable, checkable, @@ -994,7 +994,6 @@ export default defineComponent({ height, itemHeight, virtual, - titleRender, dropIndicatorRender, onContextmenu, onScroll, @@ -1014,6 +1013,7 @@ export default defineComponent({ switcherIcon, draggable, checkable, + customCheckable: slots.checkable, checkStrictly, disabled, keyEntities: keyEntities.value, @@ -1029,7 +1029,7 @@ export default defineComponent({ loadData, filterTreeNode, - titleRender, + titleRender: slots.title, onNodeClick, onNodeDoubleClick, @@ -1084,7 +1084,6 @@ export default defineComponent({ onScroll={onScroll} {...treeNodeRequiredProps.value} {...domProps} - v-slots={slots} /> diff --git a/components/vc-tree/TreeNode.tsx b/components/vc-tree/TreeNode.tsx index 83a70d556..0326bdd8d 100644 --- a/components/vc-tree/TreeNode.tsx +++ b/components/vc-tree/TreeNode.tsx @@ -293,7 +293,7 @@ export default defineComponent({ )} onClick={onCheck} > - {slots.checkable?.()} + {context.value.customCheckable?.()} ); }; diff --git a/components/vc-tree/contextTypes.ts b/components/vc-tree/contextTypes.ts index 0ec4d032f..29fcd75c3 100644 --- a/components/vc-tree/contextTypes.ts +++ b/components/vc-tree/contextTypes.ts @@ -41,7 +41,8 @@ export interface TreeContextProps { icon: IconType; switcherIcon: IconType; draggable: ((node: DataNode) => boolean) | boolean; - checkable: boolean | VueNode; + checkable: boolean; + customCheckable: () => any; checkStrictly: boolean; disabled: boolean; keyEntities: Record; diff --git a/components/vc-tree/props.ts b/components/vc-tree/props.ts index 9ac8eb0fc..73ff94ffa 100644 --- a/components/vc-tree/props.ts +++ b/components/vc-tree/props.ts @@ -132,7 +132,7 @@ export const treeProps = () => ({ defaultSelectedKeys: { type: Array as PropType }, selectedKeys: { type: Array as PropType }, allowDrop: { type: Function as PropType }, - titleRender: { type: Function as PropType<(node: DataNode) => any> }, + // titleRender: { type: Function as PropType<(node: DataNode) => any> }, dropIndicatorRender: { type: Function as PropType< (props: { diff --git a/examples/App.vue b/examples/App.vue index ed81c908f..cb7db35dd 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -2,60 +2,44 @@ - - + />