v:model vue code example
Example 1: radio button vue
<input type="radio" id="one" value="One" v-model="picked">
<label for="one">One</label>
<br>
<input type="radio" id="two" value="Two" v-model="picked">
<label for="two">Two</label>
<br>
<span>Picked: {{ picked }}</span>
Example 2: vue v-model
<input v-model="message" placeholder="edit me">
<p>Message is: {{ message }}</p>
Example 3: what does v-model do in vue
Although a bit magical, v-model is essentially syntax sugar for updating
data on user input events, plus special care for some edge cases.
Example 4: v-model= selected events
<select name="LeaveType" @change="onChange($event)" class="form-control" v-model="key">
<option value="1">Annual Leave/ Off-Day</option>
<option value="2">On Demand Leave</option>
</select>
<script>
var vm = new Vue({
data: {
key: ""
},
methods: {
onChange(event) {
console.log(event.target.value)
}
}
}
</script>