Skip to main content

{#key ...}

{#key expression}...{/key}

当表达式的值发生变化时,键块会销毁并重新创建其内容。当在组件周围使用时,这将导致它们被重新实例化和重新初始化:

¥Key blocks destroy and recreate their contents when the value of an expression changes. When used around components, this will cause them to be reinstantiated and reinitialised:

{#key value}
	<Component />
{/key}

如果你希望在值发生变化时播放过渡,它也很有用:

¥It’s also useful if you want a transition to play whenever a value changes:

{#key value}
	<div transition:fade>{value}</div>
{/key}
上一页 下一页