Skip to content

Commit 302a94c

Browse files
authored
[zh-cn] format & typo (#963)
* [zh-cn] fixed all broken anchors * [zh-cn] format fixing * [zh-cn] fixed plural en words * [zh-cn] small fixes * [zh-cn] fixed some translation of "helper" * [zh-cn] small fixes * [zh-cn] synced #6d314b3 in en
1 parent e22ae2b commit 302a94c

15 files changed

+82
-83
lines changed

docs/zh-cn/SUMMARY.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
- [开始](getting-started.md)
1212
- [核心概念](core-concepts.md)
1313
- [State](state.md)
14-
- [Getters](getters.md)
15-
- [Mutations](mutations.md)
16-
- [Actions](actions.md)
17-
- [Modules](modules.md)
14+
- [Getter](getters.md)
15+
- [Mutation](mutations.md)
16+
- [Action](actions.md)
17+
- [Module](modules.md)
1818
- [项目结构](structure.md)
1919
- [插件](plugins.md)
2020
- [严格模式](strict.md)

docs/zh-cn/actions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Actions
1+
# Action
22

33
Action 类似于 mutation,不同在于:
44

@@ -72,7 +72,7 @@ store.dispatch({
7272
})
7373
```
7474

75-
来看一个更加实际的购物车示例,涉及到**调用异步 API** **分发多重 mutations**
75+
来看一个更加实际的购物车示例,涉及到**调用异步 API****分发多重 mutation**
7676

7777
``` js
7878
actions: {
@@ -106,23 +106,23 @@ export default {
106106
// ...
107107
methods: {
108108
...mapActions([
109-
'increment', // 将 this.increment() 映射为 this.$store.dispatch('increment')
109+
'increment', //`this.increment()` 映射为 `this.$store.dispatch('increment')`
110110

111111
// `mapActions` 也支持载荷:
112112
'incrementBy' // 将 `this.incrementBy(amount)` 映射为 `this.$store.dispatch('incrementBy', amount)`
113113
]),
114114
...mapActions({
115-
add: 'increment' // 将 this.add() 映射为 this.$store.dispatch('increment')
115+
add: 'increment' //`this.add()` 映射为 `this.$store.dispatch('increment')`
116116
})
117117
}
118118
}
119119
```
120120

121-
### 组合 Actions
121+
### 组合 Action
122122

123123
Action 通常是异步的,那么如何知道 action 什么时候结束呢?更重要的是,我们如何才能组合多个 action,以处理更加复杂的异步流程?
124124

125-
首先,你需要明白 `store.dispatch` 可以处理被触发的action的回调函数返回的Promise,并且store.dispatch仍旧返回Promise
125+
首先,你需要明白 `store.dispatch` 可以处理被触发的 action 的处理函数返回的 Promise,并且 `store.dispatch` 仍旧返回 Promise
126126

127127
``` js
128128
actions: {

docs/zh-cn/api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ const store = new Vuex.Store({ ...options })
127127

128128
- **`commit(type: string, payload?: any, options?: Object) | commit(mutation: Object, options?: Object)`**
129129

130-
提交 mutation。`options` 里可以有 `root: true`,它允许在[命名空间模块](modules.md#namespacing)里提交根的 mutation。[详细介绍](mutations.md)
130+
提交 mutation。`options` 里可以有 `root: true`,它允许在[命名空间模块](modules.md#命名空间)里提交根的 mutation。[详细介绍](mutations.md)
131131

132132
- **`dispatch(type: string, payload?: any, options?: Object) | dispatch(action: Object, options?: Object)`**
133133

134-
分发 action。`options` 里可以有 `root: true`,它允许在[命名空间模块](modules.md#namespacing)里分发根的 action。返回一个解析所有被触发的 action 处理器的 Promise。[详细介绍](actions.md)
134+
分发 action。`options` 里可以有 `root: true`,它允许在[命名空间模块](modules.md#命名空间)里分发根的 action。返回一个解析所有被触发的 action 处理器的 Promise。[详细介绍](actions.md)
135135

136136
- **`replaceState(state: Object)`**
137137

@@ -158,11 +158,11 @@ const store = new Vuex.Store({ ...options })
158158

159159
- **`registerModule(path: string | Array<string>, module: Module)`**
160160

161-
注册一个动态模块。[详细介绍](modules.md#dynamic-module-registration)
161+
注册一个动态模块。[详细介绍](modules.md#模块动态注册)
162162

163163
- **`unregisterModule(path: string | Array<string>)`**
164164

165-
卸载一个动态模块。[详细介绍](modules.md#dynamic-module-registration)
165+
卸载一个动态模块。[详细介绍](modules.md#模块动态注册)
166166

167167
- **`hotUpdate(newOptions: Object)`**
168168

@@ -172,28 +172,28 @@ const store = new Vuex.Store({ ...options })
172172

173173
- **`mapState(namespace?: string, map: Array<string> | Object): Object`**
174174

175-
为组件创建计算属性以返回 Vuex store 中的状态。[详细介绍](state.md#the-mapstate-helper)
175+
为组件创建计算属性以返回 Vuex store 中的状态。[详细介绍](state.md#mapstate-辅助函数)
176176

177-
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#binding-helpers-with-namespace)
177+
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#带命名空间的绑定函数)
178178

179179
- **`mapGetters(namespace?: string, map: Array<string> | Object): Object`**
180180

181-
为组件创建计算属性以返回 getter 的返回值。[详细介绍](getters.md#the-mapgetters-helper)
181+
为组件创建计算属性以返回 getter 的返回值。[详细介绍](getters.md#mapgetters-辅助函数)
182182

183-
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#binding-helpers-with-namespace)
183+
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#带命名空间的绑定函数)
184184

185185
- **`mapActions(namespace?: string, map: Array<string> | Object): Object`**
186186

187-
创建组件方法分发 action。[详细介绍](actions.md#dispatching-actions-in-components)
187+
创建组件方法分发 action。[详细介绍](actions.md#在组件中分发-action)
188188

189-
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#binding-helpers-with-namespace)
189+
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#带命名空间的绑定函数)
190190

191191
- **`mapMutations(namespace?: string, map: Array<string> | Object): Object`**
192192

193-
创建组件方法提交 mutation。[详细介绍](mutations.md#commiting-mutations-in-components)
193+
创建组件方法提交 mutation。[详细介绍](mutations.md#在组件中提交-mutation)
194194

195-
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#binding-helpers-with-namespace)
195+
第一个参数是可选的,可以是一个命名空间字符串。[详细介绍](modules.md#带命名空间的绑定函数)
196196

197197
- **`createNamespacedHelpers(namespace: string): Object`**
198198

199-
创建基于命名空间的组件绑定辅助工具。其返回一个包含 `mapState``mapGetters``mapActions``mapMutations` 的对象。它们都已经绑定在了给定的命名空间上。[详细介绍](modules.md#binding-helpers-with-namespace)
199+
创建基于命名空间的组件绑定辅助函数。其返回一个包含 `mapState``mapGetters``mapActions``mapMutations` 的对象。它们都已经绑定在了给定的命名空间上。[详细介绍](modules.md#带命名空间的绑定函数)

docs/zh-cn/core-concepts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
在这一章,我们将会学到 Vue 的这些核心概念。他们是:
44
- [State](state.md)
5-
- [Getters](getters.md)
6-
- [Mutations](mutations.md)
7-
- [Actions](actions.md)
8-
- [Modules](modules.md)
5+
- [Getter](getters.md)
6+
- [Mutation](mutations.md)
7+
- [Action](actions.md)
8+
- [Module](modules.md)
99

1010
深入理解所有的概念对于使用 Vuex 来说是必要的。
1111

docs/zh-cn/forms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
假设这里的 `obj` 是在计算属性中返回的一个属于 Vuex store 的对象,在用户输入时,`v-model` 会试图直接修改 `obj.message`。在严格模式中,由于这个修改不是在 mutation 函数中执行的, 这里会抛出一个错误。
1010

11-
Vuex 的思维去解决这个问题的方法是:给 `<input>` 中绑定 value,然后侦听 `input` 或者 `change` 事件,在事件回调中调用 action:
11+
Vuex 的思维去解决这个问题的方法是:给 `<input>` 中绑定 value,然后侦听 `input` 或者 `change` 事件,在事件回调中调用 action:
1212

1313
``` html
1414
<input :value="message" @input="updateMessage">

docs/zh-cn/getters.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
# Getters
1+
# Getter
32

43
有时候我们需要从 store 中的 state 中派生出一些状态,例如对列表进行过滤并计数:
54

@@ -11,11 +10,11 @@ computed: {
1110
}
1211
```
1312

14-
如果有多个组件需要用到此属性,我们要么复制这个函数,或者抽取到一个共享函数然后在多处导入它 —— 无论哪种方式都不是很理想。
13+
如果有多个组件需要用到此属性,我们要么复制这个函数,或者抽取到一个共享函数然后在多处导入它——无论哪种方式都不是很理想。
1514

16-
Vuex 允许我们在 store 中定义『getters』(可以认为是 store 的计算属性)。就像计算属性一样,getters的返回值会根据它的依赖被缓存起来,且只有当它的依赖值发生了改变才会被重新计算。
15+
Vuex 允许我们在 store 中定义“getter”(可以认为是 store 的计算属性)。就像计算属性一样,getter 的返回值会根据它的依赖被缓存起来,且只有当它的依赖值发生了改变才会被重新计算。
1716

18-
Getters 接受 state 作为其第一个参数:
17+
Getter 接受 state 作为其第一个参数:
1918

2019
``` js
2120
const store = new Vuex.Store({
@@ -33,13 +32,13 @@ const store = new Vuex.Store({
3332
})
3433
```
3534

36-
Getters 会暴露为 `store.getters` 对象:
35+
Getter 会暴露为 `store.getters` 对象:
3736

3837
``` js
3938
store.getters.doneTodos // -> [{ id: 1, text: '...', done: true }]
4039
```
4140

42-
Getters 也可以接受其他 getters 作为第二个参数:
41+
Getter 也可以接受其他 getter 作为第二个参数:
4342

4443
``` js
4544
getters: {
@@ -81,15 +80,15 @@ store.getters.getTodoById(2) // -> { id: 2, text: '...', done: false }
8180

8281
### `mapGetters` 辅助函数
8382

84-
`mapGetters` 辅助函数仅仅是将 store 中的 getters 映射到局部计算属性:
83+
`mapGetters` 辅助函数仅仅是将 store 中的 getter 映射到局部计算属性:
8584

8685
``` js
8786
import { mapGetters } from 'vuex'
8887

8988
export default {
9089
// ...
9190
computed: {
92-
// 使用对象展开运算符将 getters 混入 computed 对象中
91+
// 使用对象展开运算符将 getter 混入 computed 对象中
9392
...mapGetters([
9493
'doneTodosCount',
9594
'anotherGetter',
@@ -103,7 +102,7 @@ export default {
103102

104103
``` js
105104
mapGetters({
106-
// 映射 this.doneCount 为 store.getters.doneTodosCount
105+
// 映射 `this.doneCount``store.getters.doneTodosCount`
107106
doneCount: 'doneTodosCount'
108107
})
109108
```

docs/zh-cn/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# 开始
22

3-
每一个 Vuex 应用的核心就是 store(仓库)。"store" 基本上就是一个容器,它包含着你的应用中大部分的**状态(state)**。Vuex 和单纯的全局对象有以下两点不同:
3+
每一个 Vuex 应用的核心就是 store(仓库)。store基本上就是一个容器,它包含着你的应用中大部分的**状态 (state)**。Vuex 和单纯的全局对象有以下两点不同:
44

55
1. Vuex 的状态存储是响应式的。当 Vue 组件从 store 中读取状态的时候,若 store 中的状态发生变化,那么相应的组件也会相应地得到高效更新。
66

7-
2. 你不能直接改变 store 中的状态。改变 store 中的状态的唯一途径就是显式地**提交(commit) mutations**。这样使得我们可以方便地跟踪每一个状态的变化,从而让我们能够实现一些工具帮助我们更好地了解我们的应用。
7+
2. 你不能直接改变 store 中的状态。改变 store 中的状态的唯一途径就是显式地**提交 (commit) mutation**。这样使得我们可以方便地跟踪每一个状态的变化,从而让我们能够实现一些工具帮助我们更好地了解我们的应用。
88

99
### 最简单的 Store
1010

1111
> **提示:**我们将在后续的文档示例代码中使用 ES2015 语法。如果你还没能掌握 ES2015,[你得抓紧了](https://babeljs.io/docs/learn-es2015/)
1212
13-
[安装](installation.md) Vuex 之后,让我们来创建一个 store。创建过程直截了当——仅需要提供一个初始 state 对象和一些 mutations
13+
[安装](installation.md) Vuex 之后,让我们来创建一个 store。创建过程直截了当——仅需要提供一个初始 state 对象和一些 mutation
1414

1515
``` js
1616
// 如果在模块化构建系统中,请确保在开头调用了 Vue.use(Vuex)
@@ -37,7 +37,7 @@ console.log(store.state.count) // -> 1
3737

3838
再次强调,我们通过提交 mutation 的方式,而非直接改变 `store.state.count`,是因为我们想要更明确地追踪到状态的变化。这个简单的约定能够让你的意图更加明显,这样你在阅读代码的时候能更容易地解读应用内部的状态改变。此外,这样也让我们有机会去实现一些能记录每次状态改变,保存状态快照的调试工具。有了它,我们甚至可以实现如时间穿梭般的调试体验。
3939

40-
由于 store 中的状态是响应式的,在组件中调用 store 中的状态简单到仅需要在计算属性中返回即可。触发变化也仅仅是在组件的 methods 中提交 mutations
40+
由于 store 中的状态是响应式的,在组件中调用 store 中的状态简单到仅需要在计算属性中返回即可。触发变化也仅仅是在组件的 methods 中提交 mutation
4141

4242
这是一个[最基本的 Vuex 记数应用](https://jsfiddle.net/n9jmu5v7/1269/)示例。
4343

docs/zh-cn/hot-reload.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 热重载
22

3-
使用 webpack 的 [Hot Module Replacement API](https://webpack.github.io/docs/hot-module-replacement.html),Vuex 支持在开发过程中热重载 mutation、modules、actions、和getters。你也可以在 Browserify 中使用 [browserify-hmr](https://github.com/AgentME/browserify-hmr/) 插件。
3+
使用 webpack 的 [Hot Module Replacement API](https://webpack.github.io/docs/hot-module-replacement.html),Vuex 支持在开发过程中热重载 mutation、module、action 和 getter。你也可以在 Browserify 中使用 [browserify-hmr](https://github.com/AgentME/browserify-hmr/) 插件。
44

55
对于 mutation 和模块,你需要使用 `store.hotUpdate()` 方法:
66

@@ -24,13 +24,13 @@ const store = new Vuex.Store({
2424
})
2525

2626
if (module.hot) {
27-
// 使 actionsmutations 成为可热重载模块
27+
// 使 actionmutation 成为可热重载模块
2828
module.hot.accept(['./mutations', './modules/a'], () => {
2929
// 获取更新后的模块
30-
// 因为 babel 6 的模块编译格式问题,这里需要加上 .default
30+
// 因为 babel 6 的模块编译格式问题,这里需要加上 `.default`
3131
const newMutations = require('./mutations').default
3232
const newModuleA = require('./modules/a').default
33-
// 加载新模块
33+
// 加载新模块
3434
store.hotUpdate({
3535
mutations: newMutations,
3636
modules: {

docs/zh-cn/intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ new Vue({
3030
这个状态自管理应用包含以下几个部分:
3131

3232
- **state**,驱动应用的数据源;
33-
- **view**,以声明方式将**state**映射到视图;
34-
- **actions**,响应在**view**上的用户输入导致的状态变化。
33+
- **view**,以声明方式将 **state** 映射到视图;
34+
- **actions**,响应在 **view** 上的用户输入导致的状态变化。
3535

3636
以下是一个表示“单向数据流”理念的极简示意:
3737

38-
<p style="text-align: center; margin: 2em">
39-
<img style="width:100%;max-width:450px;" src="./images/flow.png">
38+
<p style="text-align: center; margin: 2em;">
39+
<img style="width: 100%; max-width: 450px;" src="./images/flow.png">
4040
</p>
4141

4242
但是,当我们的应用遇到**多个组件共享状态**时,单向数据流的简洁性很容易被破坏:

docs/zh-cn/modules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Modules
1+
# Module
22

33
由于使用单一状态树,应用的所有状态会集中到一个比较大的对象。当应用变得非常复杂时,store 对象就有可能变得相当臃肿。
44

@@ -51,7 +51,7 @@ const moduleA = {
5151
}
5252
```
5353

54-
同样,对于模块内部的 action,局部状态通过 `context.state` 暴露出来, 根节点状态则为 `context.rootState`
54+
同样,对于模块内部的 action,局部状态通过 `context.state` 暴露出来,根节点状态则为 `context.rootState`
5555

5656
``` js
5757
const moduleA = {
@@ -206,7 +206,7 @@ methods: {
206206
}
207207
```
208208

209-
而且,你可以通过使用 `createNamespacedHelpers` 创建基于某个命名空间辅助工具。它返回一个对象,对象里有新的绑定在给定命名空间值上的组件绑定辅助工具
209+
而且,你可以通过使用 `createNamespacedHelpers` 创建基于某个命名空间辅助函数。它返回一个对象,对象里有新的绑定在给定命名空间值上的组件绑定辅助函数
210210

211211
``` js
212212
import { createNamespacedHelpers } from 'vuex'

0 commit comments

Comments
 (0)