소스 검색

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')
       }
       }
     }
     }