在 [[Svelte]] 中通过 $state 创建响应式状态,当状态发生变化时,对应 UI 也会同步响应。 使用 点击按钮时,会同步更新: 1<script>2 let count = $state(0);3</script>4 5<button onclick={() => count++}>6 clicks: {count}7</button>