Skip to content

Commit

Permalink
update apimd's doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan.Huang committed Mar 25, 2016
1 parent 3208973 commit 4a332b8
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions docs/zh-cn/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,47 @@ import Vuex from 'vuex'
const store = new Vuex.Store({ ...options })
```

### Vuex.Store 构造选项
### Vuex.Store 构造器选项

- **state**

- type: `Object`

Vuex 实例中 state 对象的根
Vuex store 实例的根 state 对象

[详细](state.md)

- **mutations**

- type: `Object | Array<Object>`

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

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

[详细](mutations.md)

- **actions**

- type: `Object | Array<Object>`

一个以 action 名为 key 的对象,value 可能为
- **modules**

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

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

如果传来一个对象数组,这些对象会自动合并到一个对象中。
``` js
{
key: {
state,
mutations
},
...
}
```

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

- **middlewares**

- type: `Array<Object>`

中间件对象的数组。中间件对象是这样的
中间件对象的数组,形如

``` js
{
Expand All @@ -57,14 +58,14 @@ const store = new Vuex.Store({ ...options })
}
```

所有属性都是可选的. [详细](middlewares.md)
所有字段都是可选的. [详细](middlewares.md)

- **strict**

- type: `Boolean`
- default: `false`

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

[详细](strict.md)

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

根 state,只读。

- **actions**

- type: `Object`

可被调用的 action 函数。

### Vuex.Store 实例方法

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

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

- **watch(pathOrGetter: String|Function, cb: Function, [options: Object])**

监听一个 path 或 getter 的值,当值发生改变时触发回调。接受与 `vm.$watch` 方法相同的配置选项作为可选参数。

执行返回的 handle function 结束监听。

- **hotUpdate(newOptions: Object)**

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

0 comments on commit 4a332b8

Please sign in to comment.