Browse Source

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 years ago
parent
commit
5ea7038903
1 changed files with 2 additions and 2 deletions
  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 = {
   // ...
   actions: {
-    incrementIfOdd ({ state, commit }) {
-      if (state.count % 2 === 1) {
+    incrementIfOddOnRootSum ({ state, commit, rootState }) {
+      if (state.count + rootState.count % 2 === 1) {
         commit('increment')
       }
     }