November 2017
Beginner to intermediate
398 pages
8h 42m
English
The namespaced option tells Vuex to also add the 'maps/' namespace before all the getter, mutation, and action types of the module. It will also add them to the commit and dispatch calls inside the namespaced module.
Let's add a few getters that will be used by the BlogMap component:
getters: { center: state => state.center, zoom: state => state.zoom,},
The maps/center and the maps/zoom getters will be added to the store. To read them, you could do:
this.$store.getters['maps/center']
With the getter helper:
mapGetters({ center: 'maps/center', zoom: 'maps/zoom',})
You can also specify a namespace parameter:
...mapGetters('maps', [ 'center', 'zoom',]),...mapGetters('some/nested/module', [ // ...]),
The last way to do it is ...
Read now
Unlock full access