How to access Vuex module getters and mutations?

后端 未结 6 1353
长发绾君心
长发绾君心 2021-01-30 13:04

I\'m trying to switch to using Vuex instead of my homegrown store object, and I must say I\'m not finding the docs as clear as elsewhere in the Vue.js world. Let\'s say I have a

6条回答
  •  情深已故
    2021-01-30 13:21

    As another addition to the accepted answer, if you need to pass parameter(s) to the getter (for instance to fetch a specific item from the store collection), you need to pass it as follows:

    this.$store.getters['yourModuleName/someGetterMethod'](myParam)
    

    I don't think I like this notation very much, but it is what it is - at least for the moment.

提交回复
热议问题