]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: formatting (#2063)
authorNed <57580045+wangenze267@users.noreply.github.com>
Thu, 9 Mar 2023 08:10:04 +0000 (16:10 +0800)
committerGitHub <noreply@github.com>
Thu, 9 Mar 2023 08:10:04 +0000 (09:10 +0100)
packages/docs/zh/cookbook/migration-vuex.md

index 04806fba665d78a279b71d11fb4ecc6aa33cf074..2ae236f4d9b4d3f4647a06dbadc90aa8f9607ae5 100644 (file)
@@ -177,14 +177,14 @@ export const useAuthUserStore = defineStore('auth/user', {
 1. 为 store 添加一个必要的 `id`,你可以让它与之前的命名保持相同。
 2. 如果 `state` 不是一个函数的话 将它转换为一个函数。
 3. 转换 `getters`
-    1. 删除任何返回同名 state 的 getters(例如: `firstName: (state) => state.firstName`),这些都不是必需的,因为你可以直接从 store 实例中访问任何状态。
+    1. 删除任何返回同名 state 的 getters (例如: `firstName: (state) => state.firstName`),这些都不是必需的,因为你可以直接从 store 实例中访问任何状态。
     2. 如果你需要访问其他的 getter,可通过 `this` 访问它们,而不是第二个参数。记住,如果你使用 `this`,而且你不得不使用一个普通函数,而不是一个箭头函数,那么由于 TS 的限制,你需要指定一个返回类型,更多细节请阅读[这篇文档](../core-concepts/getters.md#accessing-other-getters)
     3. 如果使用 `rootState` 或 `rootGetters` 参数,可以直接导入其他 store 来替代它们,或者如果它们仍然存在于 Vuex ,则直接从 Vuex 中访问它们。
 4. 转换 `actions`
     1. 从每个 action 中删除第一个 `context` 参数。所有的东西都应该直接从 `this` 中访问。
     2. 如果使用其他 store,要么直接导入,要么与 getters 一样,在 Vuex 上访问。
 5. 转换 `mutations`
-    1. Mutation 已经被弃用了。它们可以被转换为 `action`,或者你可以在你的组件中直接赋值给 store(例如,`userStore.firstName = 'First'`)
+    1. Mutation 已经被弃用了。它们可以被转换为 `action`,或者你可以在你的组件中直接赋值给 store (例如:`userStore.firstName = 'First'`)
     2. 如果你想将它转换为 action,删除第一个 `state` 参数,用 `this` 代替任何赋值操作中的 `state`。
     3. 一个常见的 mutation 是将 state 重置为初始 state。而这就是 store 的 `$reset` 方法的内置功能。注意,这个功能只存在于 option stores。