Vue.js question detail
How to use model directive with two way computed property?
You can still use model directive using two-way computed property with a setter.
<input v-model="username">
computed: {
username: {
get () {
return this.$store.state.user.username
},
set (value) {
this.$store.commit('updateProfile', value)
}
}
}
mutations: {
updateProfile (state, username) {
state.user.username = username
}
}