You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/dynamic-component-slot/main.svelte

35 lines
560 B

<script>
import Foo from './Foo.svelte';
import Bar from './Bar.svelte';
import Baz from './Baz.svelte';
export let x;
export let tag = 'you\'re it';
export let foo;
export let bar;
export let things = ['a', 'b', 'c'];
</script>
<svelte:component this="{ x ? Foo : Bar }" x='{x}'>
<p>element</p>
{tag}
{#if foo}
<p>foo</p>
{:elseif bar}
<p>bar</p>
{:else}
<p>neither foo nor bar</p>
{/if}
text
{#each things as thing}
<span>{thing}</span>
{/each}
<Baz/>
<div slot='other'>what goes up must come down</div>
</svelte:component>