mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Tag): incorrect transition when set closeable dynamically
This commit is contained in:
parent
6c5cb8827b
commit
fe6e2f29ba
@ -83,6 +83,7 @@
|
||||
}
|
||||
|
||||
&__close {
|
||||
min-width: 1em;
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
@ -44,31 +44,30 @@ function Tag(
|
||||
classes[size] = size;
|
||||
}
|
||||
|
||||
const Content = (
|
||||
<span
|
||||
style={style}
|
||||
class={[bem([classes, type]), { [BORDER_SURROUND]: plain }]}
|
||||
{...inherit(ctx, true)}
|
||||
>
|
||||
{slots.default?.()}
|
||||
{props.closeable && (
|
||||
<Icon
|
||||
name="cross"
|
||||
class={bem('close')}
|
||||
onClick={(event: PointerEvent) => {
|
||||
event.stopPropagation();
|
||||
emit(ctx, 'close');
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
const CloseIcon = props.closeable && (
|
||||
<Icon
|
||||
name="cross"
|
||||
class={bem('close')}
|
||||
onClick={(event: PointerEvent) => {
|
||||
event.stopPropagation();
|
||||
emit(ctx, 'close');
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
if (props.closeable) {
|
||||
return <transition name="van-fade">{Content}</transition>;
|
||||
}
|
||||
|
||||
return Content;
|
||||
return (
|
||||
<transition name={props.closeable ? 'van-fade' : ''}>
|
||||
<span
|
||||
key="content"
|
||||
style={style}
|
||||
class={[bem([classes, type]), { [BORDER_SURROUND]: plain }]}
|
||||
{...inherit(ctx, true)}
|
||||
>
|
||||
{slots.default?.()}
|
||||
{CloseIcon}
|
||||
</span>
|
||||
</transition>
|
||||
);
|
||||
}
|
||||
|
||||
Tag.props = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user