!tampil)}>Toggle</button> {#if tampil} <div transition:fade={{ duration: 300 }}> Konten muncul dengan efek fade! </div> {/if} Svelte Store Store digunakan untuk mengelola state global. Contoh Writable Store: // stores.js import { writable } from "svelte/store"; export const ... pesan = writable("Halo!"); <!-- App.svelte --> <script> import { pesan } from "./stores.js"; </script> <p>{$pesan}</p> <button on:click={() => $pesan = "Selamat datang!"}>Ubah Pesan</button> Photo by Christopher Gower on Unsplash Kesimpulan Svelte
Store Global
- Home
- Store Global