We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac1d747 commit fb18157Copy full SHA for fb18157
vuex-learn.md
@@ -100,6 +100,7 @@ const mutations = {
100
> 来源:https://vuex.vuejs.org/zh-cn/actions.html
101
102
```js
103
+// 建议把此区当做事件注册来看, action 也不是马上就执行,只向 mutation 做 commit 的指令。
104
105
const actions = {
106
increment: ({
@@ -116,6 +117,8 @@ const actions = {
116
117
commit('increment')
118
}
119
},
120
+
121
+ // 如果 action 有异步的要求时,可以参考下列的写法,对 mutation 提出 commit 。
122
incrementAsync({
123
commit
124
}) {
@@ -129,6 +132,20 @@ const actions = {
129
132
130
133
```
131
134
135
+## 观念讲解 : vuex,action ,mutations 做什么用的?(4) getters
136
137
+> 请当做 计算属性来写,所有的 getter, 接收 完整的state树,做第一个参数
138
139
+``` js
140
+const getters = {
141
+ evenOrOdd: state => state.count % 2 === 0 ? '偶数' : '奇数'
142
+}
143
144
+```
145
146
147
148
149
150
151
0 commit comments