mirror of https://github.com/sveltejs/svelte
21 lines
325 B
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>
|