Skip to content

Commit 16cc666

Browse files
authored
add a note that registerModule can receive an array of string (vuejs#634)
1 parent bb083ce commit 16cc666

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/en/modules.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,18 @@ export function createPlugin (options = {}) {
227227
You can register a module **after** the store has been created with the `store.registerModule` method:
228228

229229
``` js
230+
// register a module `myModule`
230231
store.registerModule('myModule', {
231232
// ...
232233
})
234+
235+
// register a nested module `nested/myModule`
236+
store.registerModule(['nested', 'myModule'], {
237+
// ...
238+
})
233239
```
234240

235-
The module's state will be exposed as `store.state.myModule`.
241+
The module's state will be exposed as `store.state.myModule` and `store.state.nested.myModule`.
236242

237243
Dynamic module registration makes it possible for other Vue plugins to also leverage Vuex for state management by attaching a module to the application's store. For example, the [`vuex-router-sync`](https://github.com/vuejs/vuex-router-sync) library integrates vue-router with vuex by managing the application's route state in a dynamically attached module.
238244

0 commit comments

Comments
 (0)