From ad91b8ac82a0081e1873a411440fd0de601ce0bc Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 23 Oct 2023 09:57:35 +0800 Subject: [PATCH] fix: not inherit slot and not show icon slot --- src/components/Tree/src/BasicTree.vue | 14 +++++++++++--- src/components/Tree/src/TreeIcon.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Tree/src/BasicTree.vue b/src/components/Tree/src/BasicTree.vue index 680abc2c..2d23abfe 100644 --- a/src/components/Tree/src/BasicTree.vue +++ b/src/components/Tree/src/BasicTree.vue @@ -368,15 +368,21 @@ export default defineComponent({ : ( title ) + + const iconDom = icon ? () : slots.icon ? ({getSlot(slots, 'icon')}) : null + item[titleField] = ( {slots?.title ? ( - getSlot(slots, 'title', item) + <> + {iconDom} + {getSlot(slots, 'title', item)} + ) : ( <> - {icon && } + {iconDom} {titleDom} {renderAction(item)} @@ -415,7 +421,9 @@ export default defineComponent({ )} - + + {extendSlots(slots, ['title'])} + diff --git a/src/components/Tree/src/TreeIcon.ts b/src/components/Tree/src/TreeIcon.ts index ffc08cc9..bcfc3e04 100644 --- a/src/components/Tree/src/TreeIcon.ts +++ b/src/components/Tree/src/TreeIcon.ts @@ -4,7 +4,7 @@ import { h } from 'vue' import { isString } from '@/utils/is' import { Icon } from '@/components/Icon' -export const TreeIcon: FunctionalComponent = ({ icon }: { icon: VNode | string }) => { +export const TreeIcon: FunctionalComponent = ({ icon }: { icon: VNode | string | undefined }) => { if (!icon) return null if (isString(icon))