Преглед изворни кода

Add rootState to module action's example code (#581)

This matches the description above, where `context.rootState` is mentioned but does not appear in the example code previously.
Tao Guo пре 8 година
родитељ
комит
5ea7038903
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2 2
      docs/en/modules.md

+ 2 - 2
docs/en/modules.md

@@ -57,8 +57,8 @@ Similarly, inside module actions, `context.state` will expose the local state, a
 const moduleA = {
 const moduleA = {
   // ...
   // ...
   actions: {
   actions: {
-    incrementIfOdd ({ state, commit }) {
-      if (state.count % 2 === 1) {
+    incrementIfOddOnRootSum ({ state, commit, rootState }) {
+      if (state.count + rootState.count % 2 === 1) {
         commit('increment')
         commit('increment')
       }
       }
     }
     }