我正在尝试循环遍历数组以呈现具有 值的组件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}
Run Code Online (Sandbox Code Playgroud)
期望的输出:
<One />
<Two />
<Three />
<One />
Run Code Online (Sandbox Code Playgroud)
做这个的最好方式是什么?
svelte ×1