|
@@ -22,7 +22,7 @@ const store = new Vuex.Store({ ...options })
|
|
|
|
|
|
- 类型: `{ [type: string]: Function }`
|
|
|
|
|
|
- 在 store 上注册 mutation,处理函数总是接受 `state` 作为第一个参数(如果定义在模块中,则为模块的本地状态),`payload` 作为第二个参数(可选)。
|
|
|
+ 在 store 上注册 mutation,处理函数总是接受 `state` 作为第一个参数(如果定义在模块中,则为模块的局部状态),`payload` 作为第二个参数(可选)。
|
|
|
|
|
|
[详细介绍](mutations.md)
|
|
|
|
|
@@ -34,7 +34,7 @@ const store = new Vuex.Store({ ...options })
|
|
|
|
|
|
``` js
|
|
|
{
|
|
|
- state, // 等同于 store.state, 若在模块中则为本地状态
|
|
|
+ state, // 等同于 store.state, 若在模块中则为局部状态
|
|
|
rootState, // 等同于 store.state, 只存在于模块中
|
|
|
commit, // 等同于 store.commit
|
|
|
dispatch, // 等同于 store.dispatch
|
|
@@ -49,9 +49,9 @@ const store = new Vuex.Store({ ...options })
|
|
|
- 类型: `{ [key: string]: Function }`
|
|
|
|
|
|
在 store 上注册 getter,getter 方法接受以下参数:
|
|
|
-
|
|
|
+
|
|
|
```
|
|
|
- state, // 如果在模块中定义则为模块的本地状态
|
|
|
+ state, // 如果在模块中定义则为模块的局部状态
|
|
|
getters, // 等同于 store.getters
|
|
|
rootState // 等同于 store.state
|
|
|
```
|
|
@@ -78,7 +78,7 @@ const store = new Vuex.Store({ ...options })
|
|
|
}
|
|
|
```
|
|
|
|
|
|
- 与根模块的选项一样,每个模块也包含 `state` 和 `mutations` 选项。模块的状态使用 key 关联到 store 的根状态。模块的 mutation 和 getter 只会接收 module 的本地状态作为第一个参数,而不是根状态,并且模块 action 的 `context.state` 同样指向本地状态。
|
|
|
+ 与根模块的选项一样,每个模块也包含 `state` 和 `mutations` 选项。模块的状态使用 key 关联到 store 的根状态。模块的 mutation 和 getter 只会接收 module 的局部状态作为第一个参数,而不是根状态,并且模块 action 的 `context.state` 同样指向局部状态。
|
|
|
|
|
|
[详细介绍](modules.md)
|
|
|
|