1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <script lang="ts"> let list:string[] = [ ]; function onClick() { list[list.length] = { id:String(list.length + 1).padStart(2, '0'), name:Math.random().toString(32).substring(2) }; } </script>
<table> {#each list as data} <tr> <td>{data.id}</td> <td>{data.name}</td> </tr> {/each} </table>
<button on:click={onClick}>Add</button>
|