Reputation: 59
error [vuex] unknown getter: counter/count`
const state = {
someRootState: 'someRootState'
}
const getters = {
getRootState: state => state.someRootState
}
import counter from './counter.js'
export default new Vuex.Store({
state,
getters,
modules:{
counter
}
})
const state = {
count: 10
}
const getters = {
getCount: state => state.count
}
export default {
namespaced: true,
state,
getters
}
import { mapGetters } from "vuex";
computed: {
//doesn't work [vuex] unknown getter: counter/count
...mapGetters("counter", [
"count"
]),
//doesn't work [vuex] unknown getter: counter/count
...mapGetters({
count: "counter/count"
}),
//work
...mapGetters(["getRootState"]),
//work
...mapGetters({
getRootState: "getRootState"
}),
}
mapStates work's right, mapGetters dont work, please help me to understand
Upvotes: 0
Views: 4344
Reputation: 23968
your getter is called getCount
, not count
, so the mapGetters
call should look like this:
...mapGetters("counter", [
"getCount"
]),
Upvotes: 5