mirror of https://github.com/sveltejs/svelte
24 lines
425 B
24 lines
425 B
<script>
|
|
import Thing from './Thing.svelte';
|
|
|
|
let things = [
|
|
{ id: 1, color: 'darkblue' },
|
|
{ id: 2, color: 'indigo' },
|
|
{ id: 3, color: 'deeppink' },
|
|
{ id: 4, color: 'salmon' },
|
|
{ id: 5, color: 'gold' }
|
|
];
|
|
|
|
function handleClick() {
|
|
things = things.slice(1);
|
|
}
|
|
</script>
|
|
|
|
<button on:click={handleClick}>
|
|
Remove first thing
|
|
</button>
|
|
|
|
{#each things as thing (thing.id)}
|
|
<Thing current={thing.color}/>
|
|
{/each}
|