Skip to content

Commit 7cf03d3

Browse files
jingsamyyx990803
authored andcommitted
本地状态 => 局部状态 (#453)
* Update state.md * 本地状态 => 局部状态
1 parent 6a12078 commit 7cf03d3

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

docs/zh-cn/api.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const store = new Vuex.Store({ ...options })
2222

2323
- 类型: `{ [type: string]: Function }`
2424

25-
在 store 上注册 mutation,处理函数总是接受 `state` 作为第一个参数(如果定义在模块中,则为模块的本地状态),`payload` 作为第二个参数(可选)。
25+
在 store 上注册 mutation,处理函数总是接受 `state` 作为第一个参数(如果定义在模块中,则为模块的局部状态),`payload` 作为第二个参数(可选)。
2626

2727
[详细介绍](mutations.md)
2828

@@ -34,7 +34,7 @@ const store = new Vuex.Store({ ...options })
3434

3535
``` js
3636
{
37-
state, // 等同于 store.state, 若在模块中则为本地状态
37+
state, // 等同于 store.state, 若在模块中则为局部状态
3838
rootState, // 等同于 store.state, 只存在于模块中
3939
commit, // 等同于 store.commit
4040
dispatch, // 等同于 store.dispatch
@@ -49,9 +49,9 @@ const store = new Vuex.Store({ ...options })
4949
- 类型: `{ [key: string]: Function }`
5050

5151
在 store 上注册 getter,getter 方法接受以下参数:
52-
52+
5353
```
54-
state, // 如果在模块中定义则为模块的本地状态
54+
state, // 如果在模块中定义则为模块的局部状态
5555
getters, // 等同于 store.getters
5656
rootState // 等同于 store.state
5757
```
@@ -78,7 +78,7 @@ const store = new Vuex.Store({ ...options })
7878
}
7979
```
8080

81-
与根模块的选项一样,每个模块也包含 `state``mutations` 选项。模块的状态使用 key 关联到 store 的根状态。模块的 mutation 和 getter 只会接收 module 的本地状态作为第一个参数,而不是根状态,并且模块 action 的 `context.state` 同样指向本地状态
81+
与根模块的选项一样,每个模块也包含 `state``mutations` 选项。模块的状态使用 key 关联到 store 的根状态。模块的 mutation 和 getter 只会接收 module 的局部状态作为第一个参数,而不是根状态,并且模块 action 的 `context.state` 同样指向局部状态
8282

8383
[详细介绍](modules.md)
8484

docs/zh-cn/forms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mutations: {
4040

4141
### 双向绑定的计算属性
4242

43-
必须承认,这样做比简单地使用“`v-model` + 本地状态”要啰嗦得多,并且也损失了一些 `v-model` 中很有用的特性。另一个方法是使用带有 setter 的双向绑定计算属性:
43+
必须承认,这样做比简单地使用“`v-model` + 局部状态”要啰嗦得多,并且也损失了一些 `v-model` 中很有用的特性。另一个方法是使用带有 setter 的双向绑定计算属性:
4444

4545
``` js
4646
// ...

docs/zh-cn/getters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ computed: {
6464

6565
### `mapGetters` 辅助函数
6666

67-
`mapGetters` 辅助函数仅仅是将 store 中的 getters 映射到 本地计算属性
67+
`mapGetters` 辅助函数仅仅是将 store 中的 getters 映射到局部计算属性
6868

6969
``` js
7070
import { mapGetters } from 'vuex'

docs/zh-cn/modules.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ store.state.a // -> moduleA 的状态
2929
store.state.b // -> moduleB 的状态
3030
```
3131

32-
### 模块的本地状态
32+
### 模块的局部状态
3333

34-
对于模块内部的 mutation 和 getter,接收的第一个参数是**模块的本地状态**
34+
对于模块内部的 mutation 和 getter,接收的第一个参数是**模块的局部状态**
3535

3636
``` js
3737
const moduleA = {
3838
state: { count: 0 },
3939
mutations: {
4040
increment: (state) {
41-
// state 模块的本地状态
41+
// state 模块的局部状态
4242
state.count++
4343
}
4444
},
@@ -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 = {

docs/zh-cn/state.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default {
7272
// 传字符串参数 'count' 等同于 `state => state.count`
7373
countAlias: 'count',
7474

75-
// 为了能够使用 `this` 获取本地状态,必须使用常规函数
75+
// 为了能够使用 `this` 获取局部状态,必须使用常规函数
7676
countPlusLocalState (state) {
7777
return state.count + this.localCount
7878
}
@@ -91,7 +91,7 @@ computed: mapState([
9191

9292
### 对象展开运算符
9393

94-
`mapState` 函数返回的是一个对象。我们如何将它与本地计算属性混合使用呢?通常,我们需要使用一个工具函数将多个对象合并为一个,以使我们可以将最终对象传给 `computed` 属性。但是自从有了[对象展开运算符](https://github.com/sebmarkbage/ecmascript-rest-spread)(现处于 ECMASCript 提案 stage-3 阶段),我们可以极大地简化写法:
94+
`mapState` 函数返回的是一个对象。我们如何将它与局部计算属性混合使用呢?通常,我们需要使用一个工具函数将多个对象合并为一个,以使我们可以将最终对象传给 `computed` 属性。但是自从有了[对象展开运算符](https://github.com/sebmarkbage/ecmascript-rest-spread)(现处于 ECMASCript 提案 stage-3 阶段),我们可以极大地简化写法:
9595

9696
``` js
9797
computed: {
@@ -103,6 +103,6 @@ computed: {
103103
}
104104
```
105105

106-
### 组件仍然保有本地状态
106+
### 组件仍然保有局部状态
107107

108-
使用 Vuex 并不意味着你需要将**所有的**状态放入 Vuex。虽然将所有的状态放到 Vuex 会使状态变化更显式和易调试,但也会使代码变得冗长和不直观。如果有些状态严格属于单个组件,最好还是作为组件的本地状态。你应该根据你的应用开发需要进行权衡和确定。
108+
使用 Vuex 并不意味着你需要将**所有的**状态放入 Vuex。虽然将所有的状态放到 Vuex 会使状态变化更显式和易调试,但也会使代码变得冗长和不直观。如果有些状态严格属于单个组件,最好还是作为组件的局部状态。你应该根据你的应用开发需要进行权衡和确定。

0 commit comments

Comments
 (0)