fix: not inherit slot and not show icon slot

pull/38/head
xingyu 2023-10-23 09:57:35 +08:00
parent b2ade25899
commit ad91b8ac82
2 changed files with 12 additions and 4 deletions

View File

@ -368,15 +368,21 @@ export default defineComponent({
: (
title
)
const iconDom = icon ? (<TreeIcon icon={icon} />) : slots.icon ? (<span class="mr-1">{getSlot(slots, 'icon')}</span>) : null
item[titleField] = (
<span class={`${bem('title')} pl-2`} onClick={handleClickNode.bind(null, item[keyField], item[childrenField])}>
{slots?.title
? (
getSlot(slots, 'title', item)
<>
{iconDom}
{getSlot(slots, 'title', item)}
</>
)
: (
<>
{icon && <TreeIcon icon={icon} />}
{iconDom}
{titleDom}
<span class={bem('actions')}>{renderAction(item)}</span>
</>
@ -415,7 +421,9 @@ export default defineComponent({
)}
<Spin wrapperClassName={unref(props.treeWrapperClassName)} spinning={unref(props.loading)} tip="加载中...">
<ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
<Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value} />
<Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value}>
{extendSlots(slots, ['title'])}
</Tree>
</ScrollContainer>
<Empty v-show={unref(getNotFound)} image={Empty.PRESENTED_IMAGE_SIMPLE} class="!mt-4" />
</Spin>

View File

@ -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))