Skip to content

Commit 9071ec3

Browse files
committed
Merge pull request #120 from ryerh/zh-cn-docs-patch
zh-cn docs patch
2 parents 3208973 + c348c68 commit 9071ec3

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

docs/zh-cn/api.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,47 @@ import Vuex from 'vuex'
88
const store = new Vuex.Store({ ...options })
99
```
1010

11-
### Vuex.Store 构造选项
11+
### Vuex.Store 构造器选项
1212

1313
- **state**
1414

1515
- type: `Object`
1616

17-
Vuex 实例中 state 对象的根
17+
Vuex store 实例的根 state 对象
1818

1919
[详细](state.md)
2020

2121
- **mutations**
2222

23-
- type: `Object | Array<Object>`
24-
25-
一个以 mutation 名为 key, mutation handler 为 value 的对象。Handler function 接受的第一个参数是 `state` 和在后面的所有 dispatch 传来的参数。
23+
- type: `Object`
2624

27-
如果传来一个对象数组,这些对象会自动合并到一个对象中
25+
一个以 mutation 名为 key, mutation handler 为 value 的对象。Handler function 永远接受 `state` 为第一个参数,后面紧跟着所有调用 dispatch 时传入的参数
2826

2927
[详细](mutations.md)
3028

31-
- **actions**
32-
33-
- type: `Object | Array<Object>`
34-
35-
一个以 action 名为 key 的对象,value 可能为
29+
- **modules**
3630

37-
1. 一个 mutation 名字的 string, 或
38-
2. 一个函数。该函数将获取 store 实例为第一个参数,以及其他可能的 payload 参数。
31+
- type: `Object`
3932

40-
Vuex 会将他们转化为可以被调用的 action 函数,并暴露到 store 实例的 `actions` 对象上。
33+
一个会被合并到 store 中包含子模块的对象,形如:
4134

42-
如果传来一个对象数组,这些对象会自动合并到一个对象中。
35+
``` js
36+
{
37+
key: {
38+
state,
39+
mutations
40+
},
41+
...
42+
}
43+
```
4344

44-
[详细](actions.md)
45+
每个模块都可以包含与根选项类似的 `state``mutations`。模块的状态会被以模块的 key 附加到 Vuex 实例的根状态中。模块的 mutations 只接受此模块的状态作为第一个参数而不是整个根状态。
4546

4647
- **middlewares**
4748

4849
- type: `Array<Object>`
4950

50-
中间件对象的数组。中间件对象是这样的
51+
中间件对象的数组,形如
5152

5253
``` js
5354
{
@@ -57,14 +58,14 @@ const store = new Vuex.Store({ ...options })
5758
}
5859
```
5960

60-
所有属性都是可选的. [详细](middlewares.md)
61+
所有字段都是可选的。[详细](middlewares.md)
6162

6263
- **strict**
6364

6465
- type: `Boolean`
6566
- default: `false`
6667

67-
使 Vuex store 实例进入严格模式。严格模式中,在 mutation handler 外部对该 store 的 state 做任何操作均会抛出错误
68+
强制 Vuex store 实例进入严格模式。在严格模式中任何在 mutation handler 外部对该 store 的 state 做出的修改均会抛出异常
6869

6970
[详细](strict.md)
7071

@@ -76,18 +77,18 @@ const store = new Vuex.Store({ ...options })
7677

7778
根 state,只读。
7879

79-
- **actions**
80-
81-
- type: `Object`
82-
83-
可被调用的 action 函数。
84-
8580
### Vuex.Store 实例方法
8681

8782
- **dispatch(mutationName: String, ...args)**
8883

8984
直接触发一个 mutation。在一些特殊情况下会需要用到这个方法,但通常来说,在组件中应当尽量通过调用 actions 来触发 mutation。
9085

86+
- **watch(pathOrGetter: String|Function, cb: Function, [options: Object])**
87+
88+
监听一个 path 或 getter 的值,当值发生改变时触发回调。接受与 `vm.$watch` 方法相同的配置选项作为可选参数。
89+
90+
执行返回的 handle function 结束监听。
91+
9192
- **hotUpdate(newOptions: Object)**
9293

93-
热更新 actions 和 mutations. [详细](hot-reload.md)
94+
热更新 actions 和 mutations[详细](hot-reload.md)

0 commit comments

Comments
 (0)