Home > Article > Web Front-end > Svelte Counter I made to understand runes
The final result.
This is the Svelte code I wrote to create a counter.
Link to code
<script> let number = $state(0); let currentValue = $derived(number); const addByOne = () => (number = 1); const decreaseByOne = () => (number > 0 ? (number -= 1) : 0); const reset = () => (number = 0); const multiplyByTwo = () => (number *= 2); </script> <div>
The above is the detailed content of Svelte Counter I made to understand runes. For more information, please follow other related articles on the PHP Chinese website!