Reputation: 166
I don't know how to call, multiple NamespacedHelpers with vuex, i tried this:
import { createNamespacedHelpers } from 'vuex'
const { mapActions, mapMutations } = createNamespacedHelpers(['payments', 'auth'])
methods: {
...mapActions(['registerBankData', 'updateBankData', 'getBankData'], ['login']),
...mapMutations(['setBankData']),
...
}
Also tried this:
import { createNamespacedHelpers } from 'vuex'
const { mapActions, mapMutations } = createNamespacedHelpers('payments', 'auth')
methods: {
...mapActions(['registerBankData', 'updateBankData', 'getBankData', 'login']),
...mapMutations(['setBankData']),
...
}
but doesn't work..
Upvotes: 3
Views: 617
Reputation: 462
I believe you can do this
import { createNamespacedHelpers } from 'vuex'
const payments = createNamespacedHelpers('payments')
const auth = createNamespacedHelpers('auth')
methods: {
...payments.mapActions(['registerBankData', 'updateBankData', 'getBankData']),
...auth.mapActions(['authAction', 'login']),
...payments.mapMutations(['setBankData']),
...
}
Upvotes: 3
Reputation: 1921
Try something like that:
import { mapMutations, mapActions } from 'vuex';
export default {
methods: {
...mapMutations({
myMutation: 'myModule/myMutation',
}),
...mapActions({
myAction: 'myModule/myAction',
}),
}
}
Upvotes: 3