Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to dynamically render components in Svelte?

$
0
0

I'm trying to loop through an array to render the component with the value of type.

<script>import One from './One.svelte';    import Two from './Two.svelte';import Three from './Three.svelte';const contents = [ {type: 'One'}, {type: 'Two'}, {type: 'Three'}, {type: 'One'}]</script>{#each contents as content}<{content.type} />{/each}

Desired output:

<One /><Two /><Three /><One />

What is the best way to do this?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>