search

Home  >  Q&A  >  body text

vuex cannot get getters in modules - vuex

I was using vuex when I started, and I found a very strange problem. It was not possible to use mapActions in modules, but when using mapGetters, an error was reported [vuex] unknown getter: user/USER_GETCOODE,
I felt very strange about this, so I added $ When the store printed it out, I found that my getters only had methods related to components, and there were no methods in modules, but _actions was normal.


getters method in modules


interface


vue calling method

巴扎黑巴扎黑2750 days ago728

reply all(2)I'll reply

  • 为情所困

    为情所困2017-05-19 10:22:27

    Getters are written in modules, but they do not belong to modules, so when using getters, it is this.$store.getters.xxxx instead of locating under a module and then calling getters.

    In addition, it is recommended that you install a Chrome plug-in for Vue Devtools, which will be more intuitive.

    Inside the

    module is getters, 不是 getter.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-19 10:22:27

    Due to neglect, the getters of modules were written as getters. After modification, the method of modules can be obtained

    reply
    0
  • Cancelreply