export default {
methods: {
// other methods properties
// useCounterStore has two actions named `increment` and `setCount`
...mapActions(useCounterStore, { moar: 'increment', setIt: 'setCount' })
},
created() {
this.moar()
this.setIt(2)
}
}
Allows directly using actions from your store without using the composition
API (setup()
) by generating an object to be spread in the methods
field
of a component.
export default {
methods: {
// other methods properties
...mapActions(useCounterStore, ['increment', 'setCount'])
},
created() {
this.increment()
this.setCount(2) // pass arguments as usual
}
}
Generated using TypeDoc
Allows directly using actions from your store without using the composition API (
setup()
) by generating an object to be spread in themethods
field of a component. The values of the object are the actions while the keys are the names of the resulting methods.