v-model principle

v-model is actually a syntactic sugar. The essence behind it contains two operations:

  • v-bind binds a value attribute
  • v-on binds the input event to the current element

That is to say, the following code is equivalent to the following code:
<input type="text" v-model="message">
equivalent to
<input type="text" v-bind:value="message" v-on:input="message = $event.target.value">

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45846359/article/details/109288657