I have been using vue/vuex for months and I see mapState
, mapGetters
, mapActions
, mapMutations
but don't know what they do except for mapState
.
This is how I use mapState
// mutations.js
user: {
address: {},
name: '',
age: ''
}
and in my code I have something like this:
import { mapState } from 'vuex'
export default {
data: {},
computed: {
...mapState({
address: state => state.user.address
})
}
}
then I can use address anywhere, but I don't know what the others are used for.
can someone give a simple example? thanks