@@ -53,8 +53,17 @@ const store = new Vuex.Store({ ...options })
5353 ```
5454 state, // 如果在模块中定义则为模块的局部状态
5555 getters, // 等同于 store.getters
56- rootState // 等同于 store.state
5756 ```
57+
58+ 当定义在一个模块里时会特别一些
59+
60+ ```
61+ state, // 如果在模块中定义则为模块的局部状态
62+ getters, // 等同于 store.getters
63+ rootState // 等同于 store.state
64+ rootGetters // 所有 getters
65+ ```
66+
5867 注册的 getter 暴露为 ` store.getters` 。
5968
6069 [详细介绍](getters .md )
@@ -69,6 +78,7 @@ const store = new Vuex.Store({ ...options })
6978 {
7079 key: {
7180 state,
81+ namespaced?,
7282 mutations,
7383 actions?,
7484 getters?,
@@ -115,14 +125,13 @@ const store = new Vuex.Store({ ...options })
115125
116126### Vuex .Store 实例方法
117127
118- - ** ` commit(type: string, payload?: any) | commit(mutation: Object)` **
119-
120- 提交 mutation。 [详细介绍](mutations .md )
128+ - ** ` commit(type: string, payload?: any, options?: Object) | commit(mutation: Object, options?: Object)` **
121129
122- - ** ` dispatch(type: string, payload?: any) | dispatch(action: Object) ` **
130+ 提交 mutation。 ` options ` 里可以有 ` root: true ` ,它允许在[命名空间模块]( modules . md #namespacing)里提交根的 mutation。[详细介绍]( mutations . md )
123131
124- 分发 action。返回 action 方法的返回值,如果多个处理函数被触发,那么返回一个 Pormise。 [详细介绍]( actions . md )
132+ - ** ` dispatch(type: string, payload?: any, options?: Object) | dispatch(action: Object, options?: Object) ` **
125133
134+ 分发 action。` options` 里可以有 ` root: true` ,它允许在[命名空间模块](modules .md #namespacing)里分发根的 action。返回一个解析所有被触发的 action 处理器的 Promise 。[详细介绍](actions .md )
126135
127136- ** ` replaceState(state: Object)` **
128137
@@ -145,34 +154,46 @@ const store = new Vuex.Store({ ...options })
145154 })
146155 ` ` `
147156
148- 通常用于插件。 [详细介绍](plugins .md )
157+ 通常用于插件。[详细介绍](plugins .md )
149158
150159- ** ` registerModule(path: string | Array<string>, module: Module)` **
151160
152- 注册一个动态模块。 [详细介绍](modules .md #dynamic- module - registration)
161+ 注册一个动态模块。[详细介绍](modules .md #dynamic- module - registration)
153162
154163- ** ` unregisterModule(path: string | Array<string>)` **
155164
156- 卸载一个动态模块。 [详细介绍](modules .md #dynamic- module - registration)
165+ 卸载一个动态模块。[详细介绍](modules .md #dynamic- module - registration)
157166
158167- ** ` hotUpdate(newOptions: Object)` **
159168
160- 热替换新的 action 和 mutation。 [详细介绍](hot- reload .md )
169+ 热替换新的 action 和 mutation。[详细介绍](hot- reload .md )
161170
162171### 组件绑定的辅助函数
163172
164- - ** ` mapState(map: Array<string> | Object): Object` **
173+ - ** ` mapState(namespace?: string, map: Array<string> | Object): Object` **
174+
175+ 为组件创建计算属性以返回 Vuex store 中的状态。[详细介绍](state .md #the- mapstate- helper)
176+
177+ 第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules .md #binding- helpers- with - namespace)
178+
179+ - ** ` mapGetters(namespace?: string, map: Array<string> | Object): Object` **
180+
181+ 为组件创建计算属性以返回 getter 的返回值。[详细介绍](getters .md #the- mapgetters- helper)
182+
183+ 第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules .md #binding- helpers- with - namespace)
184+
185+ - ** ` mapActions(namespace?: string, map: Array<string> | Object): Object` **
165186
166- 创建组件的计算属性返回 Vuex store 中的状态。 [详细介绍](state .md #the - mapstate - helper )
187+ 创建组件方法分发 action。 [详细介绍](actions .md #dispatching - actions - in - components )
167188
168- - ** ` mapGetters(map: Array<string> | Object): Object ` **
189+ 第一个参数是可选的,可以是一个命名空间字符串。[详细介绍]( modules . md #binding - helpers - with - namespace)
169190
170- 创建组件的计算属性返回 getter 的返回值。 [详细介绍]( getters . md #the - mapgetters - helper)
191+ - ** ` mapMutations(namespace?: string, map: Array<string> | Object): Object ` **
171192
172- - ** ` mapActions(map: Array<string> | Object): Object ` **
193+ 创建组件方法提交 mutation。[详细介绍]( mutations . md #commiting - mutations - in - components)
173194
174- 创建组件方法分发 action。 [详细介绍](actions .md #dispatching - actions - in - components )
195+ 第一个参数是可选的,可以是一个命名空间字符串。 [详细介绍](modules .md #binding - helpers - with - namespace )
175196
176- - ** ` mapMutations(map: Array< string> | Object ): Object` **
197+ - ** ` createNamespacedHelpers(namespace: string): Object` **
177198
178- 创建组件方法提交 mutation。 [详细介绍](mutations .md #commiting - mutations - in - components )
199+ 创建基于命名空间的组件绑定辅助工具。其返回一个包含 ` mapState ` 、 ` mapGetters ` 、 ` mapActions ` 和 ` mapMutations ` 的对象。它们都已经绑定在了给定的命名空间上。 [详细介绍](modules .md #binding - helpers - with - namespace )
0 commit comments