Eggon
Eggon

Reputation: 2386

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?

Upvotes: 4

Views: 1746

Answers (1)

kissu
kissu

Reputation: 46804

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.

Upvotes: 4

Related Questions