vue3 app problem to invoke getter from view components

16 Views Asked by At

I am trying to invoke from my component view (HomeView) the getter related to the module home (from store) in the way to access the state's variable. Here the files:

//index.js
import { createStore } from 'vuex'
import home from './home'


export default createStore({
  modules: {

    home
  }
})

//home.js 

export default {
  /* eslint-disable */

      
      
state: () => ({
    mainTxt: 'Hey you! ',
    mainTxt2:
      'hello this is a test'
)}

  getters: {
    getMainText: (state) => () => state.mainTxt,
    getMainText2: (state) => () => state.mainTxt2
  }
  
  ...etc.
}

homeView

computed: {
    ...mapGetters({
       getMainText: 'home/getMainText',
       getMainText2: 'home/getMainText2'
    }



When I try to use getters in HomeView I have multiple related errors [vuex] unknown getter:... I try to use the old approach that I use to for Vue2

getImgRow1Col2: (state) => {
     return state.imgRow1Col2
   }

but nothing... same problem. I follow this guide https://blog.logrocket.com/managing-multiple-store-modules-vuex/ Any suggestion about it ? Thanks

0

There are 0 best solutions below