vue Check box binding Example

vue Check box binding Example

Today, We want to share with you vue Check box binding Example.In this post we will show you v-checkbox, vue emit, vue js watch, hear for Setting a checkbox as checked with Vue.js we will give you demo and example for implement.In this post, we will learn about Using v-model for Two-Way Binding in Vue.js with an example.

vue Check box binding Example

There are the Following The simple About vue Check box binding Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Check box binding in Vue js, so the Binding Checkbox using Vue for this example is following below.

  Vuejs Dropdown Component with example

Check box binding in Vue js

shops data property in Vue instance

<script>
   var vm= new Vue({
      el: "#liveApp",
      data: {
          shops:["Iphones","Laptop","Mobiles"]
      },
    })
</script>

We have use vue.js v-for to iterate data the array of product

<div id='liveApp'>
        <ul>
           <li v-for="product in shops">
            <input  type="checkbox" :value='product'> {{product}}
           </li>
       </ul>
</div>

If We should to set simple checked property as the default value we can have the following simple source code

We shall change/update the shops array with objects

var vm= new Vue({
      el: "#liveApp",
      data: {
          shops:[
            {"name":"Iphones","checked":false },
            {"name":"Laptop","checked":true },
            {"name":"Mobiles","checked":false }
          ]
      },  
})

therefor now this product will have true or false data Boolean checked property

  Laravel 6 Count from Join Example

Your simple HTML source code should be changed as following below example

 <div id='liveApp'>
        <ul>
           <li v-for="product in shops">
            <input  type="checkbox" :value='product.name' v-model="product.checked"> {{product.name}}
           </li>
       </ul>
 </div>
 

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about vue Check box binding Example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.