Reputation: 3513
here is a working custom component: jsFiddle
<myselect :option="cnt" ></myselect>
above code works, now how to change it into v-model? following code won't work:
<myselect v-model="cnt"></myselect>
how to use v-model in this case? Thanks.
Upvotes: 1
Views: 3282
Reputation: 55634
From the documentation:
<input v-model="something">
is just syntactic sugar for:
<input :value="something" @input="something = $event.target.value">
In your fiddle you are still referencing an option
property, but the component no longer has one. You need to reference the value
property to get the initial value of cnt
and then emit an input
event to update the cnt
var being used as the model. https://jsfiddle.net/4yavj0en/2/
Upvotes: 7