[Vuejs]-Radio buttons binding doesn't work in VueJS

1๐Ÿ‘

โœ…

v-model is a directive with this syntax v-model="someData", you should replace : by hyphen - :

  <input type="radio" name="bar" id="bar_0" value="0" v-model="bar"> 

and add that bar property to the data object as follows :


new Vue({
  el: "#app",
  data(){
  return {
    foo: 1,
   bar:1
  } 
 },
  methods: {
    click: function()
    {
        this.foo = this.foo === 2 ? 0 : this.foo + 1;
    }
  }
})

Leave a comment