You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/zh-cn/state.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@
2
2
3
3
### 单状态树
4
4
5
-
Vuex 使用**单状态树(single state tree)**- 也就是单个对象包含整个应用的状态 and serves as the "single source of truth". This also means usually you will have only one store for each application. 单状态树使得我们能够直截了当地定位某一部分特定的状态,在 debug 的过程中也能轻易地取得当前应用状态的快照(snapshots)。
5
+
Vuex 使用**单状态树**—— 也就是单个对象作为『单一数据提供源([SSOT](https://en.wikipedia.org/wiki/Single_source_of_truth))』来管理整个应用级别的状态。这也意味着每个应用仅需一个 store 实例。单状态树使得我们能够直截了当地定位某一部分特定的状态,在调试的过程中也能轻易地取得当前应用状态的快照。
6
6
7
7
单状态树和模块化并不冲突 —— 在往后的章节里我们会讨论如何将状态管理分离到各个子模块中。
8
8
9
9
### 在 Vue 组件中获得 Vuex 状态
10
10
11
-
我们如何在我们的 Vue 组件中展示状态呢?由于 Vuex 的状态存储是动态的,从 store 中读取状态最简单的方法就是在计算属性[computed property](http://vuejs.org/guide/computed.html)中返回某个状态:
11
+
那么我们如何在 Vue 组件中展示状态呢?由于 Vuex 的状态存储是动态的,从 store 实例中读取状态最简单的方法就是在计算属性 [computed property](http://vuejs.org/guide/computed.html)中返回某个状态:
请关注特别的`vuex`部分。在这里我们指定该组件将会从 store 读取什么状态。对于每一个属性名,我们指定一个 getter 函数,这个只接受一个包含全部状态的 state 状态树作为唯一的参数,然后选择并返回一部分状态,或者根据状态得出的计算属性。返回的结果会像计算属性一样将属性名注入到组件上。
67
+
留意特殊的`vuex`选项部分,在这里我们指定该组件将会从 store 实例中读取哪些状态。每个属性名对应一个 getter 函数,该函数接收整个状态树作为唯一参数并返回状态树的一部分或计算后的新值。组件可以像使用计算属性一样通过属性名获取 getter 函数的返回值。
0 commit comments