From 8749d987b83b76c39c056bb16a2dedfd96c3b921 Mon Sep 17 00:00:00 2001 From: birchb Date: Sat, 13 Oct 2018 12:07:08 -0400 Subject: [PATCH] Update app-vuex-store.md Starting at line 114, I've added a short statement and code example on accessing properties in other modules using rootState. --- source/guide/app-vuex-store.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/guide/app-vuex-store.md b/source/guide/app-vuex-store.md index 5ac1f720..ae97b6ed 100644 --- a/source/guide/app-vuex-store.md +++ b/source/guide/app-vuex-store.md @@ -111,5 +111,13 @@ export default { ``` +## Using Multiple Modules + +Within each Vuex Module, properties are accessed as `state`, e.g., `state.drawerState = opened`. If you have multiple modules within you Vuex store, you can reference from one module to another using `rootState`. For example, if you had a separate `users` module and you needed to access the current user's userID in the `showcase` module, you could use: + +```js +const currentUser = rootState.users.currentUser.userID +``` + ## Store Code Splitting You can take advantage of the [PreFetch Feature](/guide/app-prefetch-feature.html#Store-Code-Splitting) to code split code for modules.