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.
21 lines
325 B
21 lines
325 B
5 years ago
|
<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>
|