#### 可修改的 state %{#modifiable-state}%
-如果你想修改这些 state 属性(例如,如果你有一个表单),你可以使用 `mapWritableState()` 作为代替。但注意你不能像 `mapState()` 那样传递一个函数:
+如果你想修改这些 state 属性 (例如,如果你有一个表单),你可以使用 `mapWritableState()` 作为代替。但注意你不能像 `mapState()` 那样传递一个函数:
```js
import { mapWritableState } from 'pinia'
<!-- TODO: disable this with `strictMode`, `{ noDirectPatch: true }` -->
-两种变更 store 方法的主要区别是,`$patch()` 允许你将多个变更归入 devtools 的同一个条目中。同时请注意,**直接修改 `state`,`$patch()` 也会出现在 devtools 中**,而且可以进行 time travel(在 Vue 3 中还没有)。
+两种变更 store 方法的主要区别是,`$patch()` 允许你将多个变更归入 devtools 的同一个条目中。同时请注意,**直接修改 `state`,`$patch()` 也会出现在 devtools 中**,而且可以进行 time travel (在 Vue 3 中还没有)。
## 替换 `state` %{#replacing-the-state}%
## 订阅 state %{#subscribing-to-the-state}%
-类似于 Vuex 的 [subscribe 方法](https://vuex.vuejs.org/zh/api/index.html#subscribe),你可以通过 store 的 `$subscribe()` 方法侦听 state 及其变化。比起普通的 `watch()`,使用 `$subscribe()` 的好处是 *subscriptions* 在 *patch* 后只触发一次(例如,当使用上面的函数版本时)。
+类似于 Vuex 的 [subscribe 方法](https://vuex.vuejs.org/zh/api/index.html#subscribe),你可以通过 store 的 `$subscribe()` 方法侦听 state 及其变化。比起普通的 `watch()`,使用 `$subscribe()` 的好处是 *subscriptions* 在 *patch* 后只触发一次 (例如,当使用上面的函数版本时)。
```js
cartStore.$subscribe((mutation, state) => {
})
```
-默认情况下,*state subscription* 会被绑定到添加它们的组件上(如果 store 在组件的 `setup()` 里面)。这意味着,当该组件被卸载时,它们将被自动删除。如果你想在组件卸载后依旧保留它们,请将 `{ detached: true }` 作为第二个参数,以将 *state subscription* 从当前组件中*分离*:
+默认情况下,*state subscription* 会被绑定到添加它们的组件上 (如果 store 在组件的 `setup()` 里面)。这意味着,当该组件被卸载时,它们将被自动删除。如果你想在组件卸载后依旧保留它们,请将 `{ detached: true }` 作为第二个参数,以将 *state subscription* 从当前组件中*分离*:
```vue
<script setup>