When I iterate over a dynamic component like:
<svelte:component collection={collection} uid={uid} this={upload_component}
bind:action={restart}/>
Is it possible to use a set of dynamic props for each component. Each component having it's own set of prop names and prop values.
Solution example:
<script>
import Info from './Info.svelte';
const pkgs = [{
name: 'svelte',
version: 3,
speed: 'blazing',
website: 'https://svelte.dev'
}, ];
</script>
<Info {...pkgs[0]}/>
More in this Rich Harris answer here.
Yes. You need spread props:
<svelte:component this={upload_component} bind:action={restart} {...someprops}/>
(Note that bindings and event listeners are not included in those props — but you can always pass down a callback function among your props.)
来源:https://stackoverflow.com/questions/58115156/do-dynamic-props-exist-in-svelte-3