当我迭代动态组件时,例如:
<svelte:component collection={collection} uid={uid} this={upload_component}
bind:action={restart}/>
是否可以为每个组件使用一组动态道具。每个组件都有自己的一组 prop 名称和 prop 值。
解决方案示例:
<script>
import Info from './Info.svelte';
const pkgs = [{
name: 'svelte',
version: 3,
speed: 'blazing',
website: 'https://svelte.dev'
}, ];
</script>
<Info {...pkgs[0]}/>
更多内容参见 Rich Harris 的回答here.
是的。你需要传播道具:
<svelte:component this={upload_component} bind:action={restart} {...someprops}/>
(请注意,绑定和事件侦听器是not包含在这些道具中 - 但您始终可以在道具中传递回调函数。)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)