vue regarding v-model data binding checkbox Instructions

vue.js provides many convenient command for developers, which v-model for forms of data binding is very common,

Here are the most common examples:

 

<div id='myApp'>
  <input type="checkbox" v-model="msg">angular<br>

   {{msg}}
</div>

 

<script>

new Vue({
el: "#myApp",
data: {
msg:‘’
}
}
)
</script>

Browser rendering:

          

Check to true, uncheck is false     

And data in msg if the initialization is true, the checkbox is selected by default     

 

Let's change bit of code, corresponding generally v-model are strings, this time we initially empty array []

<script>

new Vue({
el: "#myApp",
data: {
msg:[]
}
}
)
</script>

Browser rendering:

 

Guess you like

Origin www.cnblogs.com/wjx6270/p/11928834.html