mirror of https://github.com/sveltejs/svelte
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.
34 lines
651 B
34 lines
651 B
6 years ago
|
<script>
|
||
|
import Thing from './Thing.svelte';
|
||
|
|
||
|
let things = [
|
||
4 years ago
|
{ id: 1, color: 'darkblue' },
|
||
|
{ id: 2, color: 'indigo' },
|
||
|
{ id: 3, color: 'deeppink' },
|
||
|
{ id: 4, color: 'salmon' },
|
||
|
{ id: 5, color: 'gold' }
|
||
6 years ago
|
];
|
||
|
|
||
|
function handleClick() {
|
||
|
things = things.slice(1);
|
||
|
}
|
||
|
</script>
|
||
|
|
||
1 year ago
|
<button on:click={handleClick}> Remove first thing </button>
|
||
6 years ago
|
|
||
5 years ago
|
<div style="display: grid; grid-template-columns: 1fr 1fr; grid-gap: 1em">
|
||
6 years ago
|
<div>
|
||
|
<h2>Keyed</h2>
|
||
|
{#each things as thing (thing.id)}
|
||
1 year ago
|
<Thing current={thing.color} />
|
||
6 years ago
|
{/each}
|
||
|
</div>
|
||
|
|
||
|
<div>
|
||
|
<h2>Unkeyed</h2>
|
||
|
{#each things as thing}
|
||
1 year ago
|
<Thing current={thing.color} />
|
||
6 years ago
|
{/each}
|
||
|
</div>
|
||
5 years ago
|
</div>
|