diff options
author | 2024-11-14 15:31:51 +0000 | |
---|---|---|
committer | 2024-11-14 23:31:51 +0800 | |
commit | 9fc2ab8cc848739a21bfa3f754e9bec4926dc034 (patch) | |
tree | a184ada6711296569a064c01defd2fa6a74f63c5 /examples/framework-svelte/src/components/Counter.svelte | |
parent | bdc0890061533466da19660ff83a331a3136f6c4 (diff) | |
download | astro-9fc2ab8cc848739a21bfa3f754e9bec4926dc034.tar.gz astro-9fc2ab8cc848739a21bfa3f754e9bec4926dc034.tar.zst astro-9fc2ab8cc848739a21bfa3f754e9bec4926dc034.zip |
Update to svelte 5 (#12364)
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
Diffstat (limited to 'examples/framework-svelte/src/components/Counter.svelte')
-rw-r--r-- | examples/framework-svelte/src/components/Counter.svelte | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/framework-svelte/src/components/Counter.svelte b/examples/framework-svelte/src/components/Counter.svelte index 1353736aa..a11538645 100644 --- a/examples/framework-svelte/src/components/Counter.svelte +++ b/examples/framework-svelte/src/components/Counter.svelte @@ -1,5 +1,12 @@ <script lang="ts"> - let count = 0; + import type { Snippet } from 'svelte'; + + interface Props { + children?: Snippet + } + + let { children }: Props = $props(); + let count = $state(0); function add() { count += 1; @@ -11,12 +18,12 @@ </script> <div class="counter"> - <button on:click={subtract}>-</button> + <button onclick={subtract}>-</button> <pre>{count}</pre> - <button on:click={add}>+</button> + <button onclick={add}>+</button> </div> <div class="message"> - <slot /> + {@render children?.()} </div> <style> |