2👍
getters
are readonly, you can only update store state via mutations Vuex can’t match up getters to mutations automatically because they are user defined.
You can however specifically define the behaviour of get and set:
computed: {
...mapGetters(['foos']),
// Define what happens when we get and set `date`
date: {
get() {
return this.$store.state.foos.date;
},
set(newValue) {
return this.$store.commit('foos/setDate', newValue);
},
},
}
- [Vuejs]-Vue JS: Save the value of a prop in a component
- [Vuejs]-Vue.js: Assigning computed result to data property at created or mounted?
Source:stackexchange.com