fix(BasicTree): not inherit slot and not show icon slot. close #1902
This commit is contained in:
parent
7b87d6d29e
commit
a0b2a9e949
|
|
@ -393,16 +393,26 @@
|
||||||
) : (
|
) : (
|
||||||
title
|
title
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const iconDom = icon ? (
|
||||||
|
<TreeIcon icon={icon} />
|
||||||
|
) : slots.icon ? (
|
||||||
|
<span class="mr-1">{getSlot(slots, 'icon')}</span>
|
||||||
|
) : null;
|
||||||
|
|
||||||
item[titleField] = (
|
item[titleField] = (
|
||||||
<span
|
<span
|
||||||
class={`${bem('title')} pl-2`}
|
class={`${bem('title')} pl-2`}
|
||||||
onClick={handleClickNode.bind(null, item[keyField], item[childrenField])}
|
onClick={handleClickNode.bind(null, item[keyField], item[childrenField])}
|
||||||
>
|
>
|
||||||
{slots?.title ? (
|
{slots?.title ? (
|
||||||
getSlot(slots, 'title', item)
|
<>
|
||||||
|
{iconDom}
|
||||||
|
{getSlot(slots, 'title', item)}
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{icon && <TreeIcon icon={icon} />}
|
{iconDom}
|
||||||
{titleDom}
|
{titleDom}
|
||||||
<span class={bem('actions')}>{renderAction(item)}</span>
|
<span class={bem('actions')}>{renderAction(item)}</span>
|
||||||
</>
|
</>
|
||||||
|
|
@ -444,7 +454,9 @@
|
||||||
tip="加载中..."
|
tip="加载中..."
|
||||||
>
|
>
|
||||||
<ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
|
<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>
|
</ScrollContainer>
|
||||||
<Empty
|
<Empty
|
||||||
v-show={unref(getNotFound)}
|
v-show={unref(getNotFound)}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { h } from 'vue';
|
||||||
import { isString } from 'lodash-es';
|
import { isString } from 'lodash-es';
|
||||||
import Icon from '@/components/Icon/Icon.vue';
|
import Icon from '@/components/Icon/Icon.vue';
|
||||||
|
|
||||||
export const TreeIcon = ({ icon }: { icon: VNode | string }) => {
|
export const TreeIcon = ({ icon }: { icon: VNode | string | undefined }) => {
|
||||||
if (!icon) return null;
|
if (!icon) return null;
|
||||||
if (isString(icon)) {
|
if (isString(icon)) {
|
||||||
return h(Icon, { icon, class: 'mr-1' });
|
return h(Icon, { icon, class: 'mr-1' });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue