rootgetters vuex code example
Example 1: vuex getter root state
const getters = {
getParams: (state, getters, rootState) => {
return rootState.route.params
}
}
Example 2: vuex namespaced getters
computed: {
...mapState('some/nested/module', {
a: state => state.a,
b: state => state.b
}),
...mapGetters('some/nested/module', [
'someGetter', // -> this.someGetter
'someOtherGetter', // -> this.someOtherGetter
])
},
methods: {
...mapActions('some/nested/module', [
'foo', // -> this.foo()
'bar' // -> this.bar()
])
}