I have a vuex module with getters. I am using this module's getters in a vue component:
...
computed: {
...mapGetters('myCoolModule', ['isActive', 'someOtherGetter', 'yetAnotherGetter']),
}
...
I have other vuex modules that have an isActive
getter, so I would like to alias it here. I am familiar with the object syntax, i.e.,
...
computed: {
...mapGetters('myCoolModule', { myCoolModuleIsActive: 'isActive', someOtherGetter: 'someOtherGetter', yetAnotherGetter: 'yetAnotherGetter' }),
}
...
However, I do not need to alias 'someOtherGetter'
or 'yetAnotherGetter'
, and the object syntax seems to require that I do just that.
Is there a syntax to use with mapGetters such that I can alias only one of the getters?
What about using it twice ?
computed:
{
...mapGetters('myModule', {
myCoolModuleIsActive: 'isActive',
}),
...mapGetters('myModule', ['someOtherGetter', 'yetAnotherGetter']),
}
And why not namespacing your Vuex modules ? Thus name collisions like this will be avoided.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With