Difference between v-model and v-bind
We can use both v-model and v-bind in some cases but in some cases we can use only one of them. V-model is used for input and form binding. For example, with forms, we should use v-model. We cannot use v-model for html attribute binding. To make it simple let’s say v-model is a two-way binding, whereas v-bind is one-way binding. In a two way binding if you change the input value the bounded data will also change and vice-versa.
<input v-model="something">
In one way binding your input value can be changed by changing bounded data but if you change bounded data it won’t change the input value.
<input v-bind:value="something" v-on:input="something = $event.target.value">
Comments
0 comments
Please Sign in or Create an account to Post Comments