用途:为 Svelte 5 的 Runes 提供快速参考与操作指导,适用于编写响应式状态、props、计算值、副作用、attachments,或从 Svelte 4 迁移到 Svelte 5 的场景。
主要能力:覆盖 $props()、$bindable()、$derived()、$effect()、$state() 以及 @attach;说明 runes 仅限顶层使用、$derived 可被覆盖(用 const 表示只读)、对象与数组默认深度响应式、不要混用 Svelte 4/5 语法。附带参考文件:reactivity-patterns.md(各 rune 使用时机)、migration-gotchas.md(Svelte 4→5 迁移)、component-api.md($props、$bindable 模式)、snippets-vs-slots.md(新 snippet 语法)、common-mistakes.md(反模式与修复)、attachments.md(@attach 替代 use: actions)。
使用方式:按“该用哪个 rune”的对照选择:Props 用 $props(),可绑定用 $bindable(),计算用 $derived(),副作用用 $effect(),状态用 $state()。示例:let count = $state(0); const doubled = $derived(count * 2); $effect(() => { console.log(Count is ${count}); }); 模板中按钮用 onclick={() => count++} 并显示 {count} (doubled: {doubled})。事件使用 onclick 而非 on:click,布局中使用 {@render children()}。
限制:资料未提供安装命令、官方收费或平台支持信息;部分版本行为如 $derived 可重新赋值(5.25+)与“最后验证:2025-01-11”为资料标注,使用时需自行核对。