[Vuejs]-Radio buttons in Vuejs 2.0

0๐Ÿ‘

<div id="app">
  <div data-toggle="buttons" class="btn-group">
    taskTime {{ taskTime }}
    <label class="btn btn-sm btn-white active"> 
        <input type="radio" v-model="taskTime" value="7"  name="taskTime"> Week 
    </label>
    <label class="btn btn-sm btn-white"> 
        <input type="radio" v-model="taskTime" value="30" name="taskTime"> Month 
    </label>
  </div>
</div>

var vm = new Vue({
  el: '#app',
  data() {
    return {
      taskTime: null
    }
  },
  watch: {
    taskTime(newValue) {
      console.log('clicked');
    }
  }
})

This is working snippet. You missed one โ€œ}โ€ in your fiddle ๐Ÿ˜‰

jsfiddle

version with counter

And one more thing: your build system can remove console.log from final code.

Leave a comment