v-model vuex code example
Example 1: v-switch vuex store
import { mapState } from "vuex";
computed: {
...mapState(["settings"]),
computedProperty: {
get() {
return this.settings.valueInState;
},
set(valuePassedThrough) { //the value is passed through the v-model automatically
this.$store.dispatch(`storeAction`, valuePassedThrough);
}
}
}
Example 2: vue v-model
<input v-model="message" placeholder="edit me">
<p>Message is: {{ message }}</p>