Using separate files for Vuex Store in Nuxt.js
Pretty sure there is a bug in module getters _(or I'm dummy which also happens a lot)_
This works... ( in store/project.js )
{{ selected }}
...
computed: {
selected () {
return this.$store.state.projects.selected
}...
}
this does not...
computed: {
...mapGetters('projects', ['selected'])
}...
}
nor does this...
...mapGetters({
selected: 'projects/selected'
}),
nor this...
...mapGetters(['projects/selected']),
PS my getter is ... ( store.projects.js )
export const getters = {
selected () {
return state.selected
}
I've gotten this to work in plain vue/vuex so maybe I'm just messing up the NuxtJS syntax?
Hi @enricribas
I just updated the vuex-store-modules to use the getters.
It should work like this:
store/projects.js
:
export const getters = {
selected (state) {
return state.selected
}
}
And in your component:
computed: {
...mapGetters({
selected: 'projects/selected'
})
}
damn sorry. I was missing the state in the getter. Strange I didn't see an error.
what if i want to pass parameters to getter method ?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @enricribas
I just updated the vuex-store-modules to use the getters.
It should work like this:
store/projects.js
:And in your component: