Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在任何给定时间读取苗条的商店价值。我知道更新值时会调用 subscribe 方法。即使商店没有更新,我也想阅读商店。
就像任何其他变量一样,您可以在模板(标记)中使用它,并$在 store 变量前面使用它,就这么简单!
$
App.svelte
<script> import { count } from './stores.js'; </script> <h1> {$count} </h1>
商店.js
import { writable } from 'svelte/store'; export const count = writable(0);