From a0b2a9e949dbf1e149da8be757f78fa6b1cebec0 Mon Sep 17 00:00:00 2001 From: invalid w Date: Sat, 21 Oct 2023 11:48:38 +0800 Subject: [PATCH] fix(BasicTree): not inherit slot and not show icon slot. close #1902 --- src/components/Tree/src/BasicTree.vue | 18 +++++++++++++++--- src/components/Tree/src/TreeIcon.ts | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/Tree/src/BasicTree.vue b/src/components/Tree/src/BasicTree.vue index a9d3fad4..46373d2c 100644 --- a/src/components/Tree/src/BasicTree.vue +++ b/src/components/Tree/src/BasicTree.vue @@ -393,16 +393,26 @@ ) : ( 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)} @@ -444,7 +454,9 @@ tip="加载中..." > - + + {extendSlots(slots, ['title'])} + { +export const TreeIcon = ({ icon }: { icon: VNode | string | undefined }) => { if (!icon) return null; if (isString(icon)) { return h(Icon, { icon, class: 'mr-1' });