When using Vuex to do two-way bindings on my inputs using the v-model, the only thing I found was to use the method to calculate the computed properties.
For example, in my html:
<input v-model="name" ... />
And the computed property:
computed: {
name: {
get: function () {
return this.$store.state.name;
},
set: function (newValue) {
this.setNameAction(newValue);
}
}
}
Is this the best way to do two-way binding between input forms and Vuex? I am concerned about the performance of the computed setter Vue.js.
If not, then how do I make easy two-way binding using the v-model when working with a centralized repository such as Vuex?
source
share