Home  >  Article  >  Web Front-end  >  Svelte Counter I made to understand runes

Svelte Counter I made to understand runes

Susan Sarandon
Susan SarandonOriginal
2024-11-21 03:03:09985browse

The final result.
Svelte Counter I made to understand runes

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn