当我加载页面时,$greeting
显示正确的值。
出于某种原因,当我更改input
.
App.svelte
<script>
import { name, greeting } from './stores.js';
</script>
<h1>{$greeting}</h1>
<input value={$name}>
商店.js
import { writable, derived } from 'svelte/store'
export const name = writable('world')
export const greeting = derived(
name,
$name => `Hello ${$name}!`
)