Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a namespaced mapGetter in Vuex?

In my nuxt project I'm trying to use mapGetters with the rename object syntax as described in the docs. Getters are namespaced in a module called currentTournament.

This is the computed property inside a mixin:

computed: {
  ...mapGetters('currentTournament', [{ tAllowedBaskets: 'allowedBaskets' }]),
}

If I log component's this, instead of the tAllowedBaskets property a new property appears [object Object]: undefined. However, if I use the 'simple' string syntax:

...mapGetters('currentTournament', ['allowedBaskets'])

allowedBaskets property appears correctly.

Why can the object syntax be not working?

like image 573
Eggon Avatar asked Sep 06 '25 22:09

Eggon


1 Answers

The proper syntax is

...mapGetters('currentTournament', { tAllowedBaskets: 'allowedBaskets' }),

you don't need to have square brackets [] as shown in this part of the vuex documentation.

like image 82
kissu Avatar answered Sep 11 '25 01:09

kissu