I get error when i try use mapGetters
My store/index.js
import Vuex from 'vuex'
import modules from './modules'
export default () => {
return new Vuex.Store({
modules
})
}
store/modules/index.js
import homePage from './homePage'
export default {
homePage
}
store/modules/homePage.js
import getApi from '@/plugins/prismicApi'
import { GET_HOME_PAGE } from '../mutationTypes'
const state = {
homePage: null
}
const getters = {
homePage: state => state.homePage
}
const actions = {
async getHomePage ({ commit }) {
const api = await getApi()
const homePage = await api.getSingle('home_page')
commit(GET_HOME_PAGE, homePage.data)
}
}
const mutations = {
[GET_HOME_PAGE] (state, payload) {
state.homePage = payload
}
}
export default {
state,
getters,
actions,
mutations
}
I do not want namespaced modules, so I use this way of defining modules. I try set namespaced: false, but it's not help. And now my index.vue
import { mapGetters } from 'vuex'
export default {
name: 'index',
async fetch ({ store }) {
return store.dispatch('getHomePage')
},
computed: {
...mapGetters('homePage')
}
}
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2194">#c2194</a>)</em></sub></div>