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/each-block-keyed-dynamic-2/main.svelte

21 lines
325 B

<script>
let num = 0;
let cards = [];
function click() {
// updating cards via push should have no effect to the ul,
// since its being mutated instead of reassigned
cards.push(num++);
}
</script>
<button on:click={click}>
Click Me
</button>
{num}
<ul>
{#each cards as c, i (i)}
<li>{c}</li>
{/each}
</ul>