chore: improve compiled jsx code of default slot (#9676)

* chore: improve compiled jsx code of default slot

* fix: teleport not support v-slots
This commit is contained in:
neverland 2021-10-14 19:00:39 +08:00 committed by GitHub
parent 7eb9344446
commit 6799189f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 22 deletions

View File

@ -35,9 +35,12 @@ export default defineComponent({
if (slots.icon) {
return (
<Badge dot={dot} content={badge} class={bem('icon')}>
{slots.icon()}
</Badge>
<Badge
v-slots={{ default: slots.icon }}
dot={dot}
content={badge}
class={bem('icon')}
/>
);
}

View File

@ -558,6 +558,7 @@ export default defineComponent({
if (props.poppable) {
return (
<Popup
v-slots={{ default: renderCalendar }}
show={props.show}
class={bem('popup')}
round={props.round}
@ -567,9 +568,7 @@ export default defineComponent({
closeOnPopstate={props.closeOnPopstate}
closeOnClickOverlay={props.closeOnClickOverlay}
onUpdate:show={updateShow}
>
{renderCalendar()}
</Popup>
/>
);
}

View File

@ -80,9 +80,11 @@ export default defineComponent({
const renderIcon = () => {
if (slots.icon) {
return (
<Badge dot={props.dot} content={props.badge}>
{slots.icon()}
</Badge>
<Badge
v-slots={{ default: slots.icon }}
dot={props.dot}
content={props.badge}
/>
);
}

View File

@ -56,9 +56,7 @@ export default defineComponent({
});
return () => (
<Transition name="van-fade" appear>
{renderOverlay()}
</Transition>
<Transition v-slots={{ default: renderOverlay }} name="van-fade" appear />
);
},
});

View File

@ -201,13 +201,12 @@ export default defineComponent({
return (
<Transition
v-slots={{ default: renderPopup }}
name={transition || name}
appear={transitionAppear}
onAfterEnter={onOpened}
onAfterLeave={onClosed}
>
{renderPopup()}
</Transition>
/>
);
};

View File

@ -123,7 +123,12 @@ export default defineComponent({
nodes.push(<div class={bem('text')}>{getStatusText()}</div>);
}
if (status === 'loading') {
nodes.push(<Loading class={bem('loading')}>{getStatusText()}</Loading>);
nodes.push(
<Loading
v-slots={{ default: getStatusText }}
class={bem('loading')}
/>
);
}
return nodes;

View File

@ -83,9 +83,12 @@ export default defineComponent({
style={{ color }}
onClick={onClick}
>
<Badge dot={dot} content={badge} class={bem('icon')}>
{renderIcon()}
</Badge>
<Badge
v-slots={{ default: renderIcon }}
dot={dot}
content={badge}
class={bem('icon')}
/>
<div class={bem('text')}>
{slots.default?.({ active: active.value })}
</div>

View File

@ -95,6 +95,7 @@ export default defineComponent({
if (isImageFile(item)) {
return (
<Image
v-slots={{ default: renderCover }}
fit={props.imageFit}
src={item.content || item.url}
class={bem('preview-image')}
@ -102,9 +103,7 @@ export default defineComponent({
height={props.previewSize}
lazyLoad={props.lazyLoad}
onClick={onPreview}
>
{renderCover()}
</Image>
/>
);
}