Vue.js set checkbox checked
We can set checkbox checked in vue.js using v-model.
Vue.js set checkbox checked Example
Set v-model to true to make checkbox as checked. Here is an example of checkbox checked state.-
Example:
<div id="app"> <p><input type="checkbox" name="myCheckbox" v-model="myModel"/></p> <p>{{isChecked}}</p> <button @click="myFunction()">Click Me</button> </div> <script> new Vue({ el: '#app', data: { myModel:false }, methods:{ myFunction: function () { this.myModel = true; } } }); </script> |
Output of above example-

Advertisements