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.

Read Also:  Laravel 5/6/7 create custom helper Function

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.

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

Read Also:  Laravel 6 get last Insert id from query builder

<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

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

Read Also:  Angular 6 Form Validation with Message - Angular 6 Live Validation

 <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.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *