jeudi 14 décembre 2017

how to clear checkbox checked status? with vue

when i click next button, i want to remove checkbox checked status, but i don't use vue to remove it. this is demo code:

new Vue({
  el: "#app",
  data: {
    id:0, 
    items: [
    {'id':1,'name':'chk-a','options':['a1','b1','c1','d1']},
    {'id':2,'name':'chk-b','options':['a2','b2','c2','d2']},
    {'id':3,'name':'chk-c','options':['a3','b3','c3','d3']},
    {'id':4,'name':'chk-d','options':['a4','b4','c4','d4']},
    ]
  },
  methods: {
    next: function (id) {
      console.log(this.items.length)
      if(id<this.items.length){
        this.id++ 
      }
      console.log(this.id)
    }
  }
});
<script src="http://ift.tt/2ApO4yL"></script>
<div id="app">
  <h1>Checkbox</h1>
  <div v-for="item in items[id].options">
    <input type="radio" name="chk" :id="id">
    <label for="two"></label>
  </div>
  <button @click="next(id+1)">Next</button>
</div>



Aucun commentaire:

Enregistrer un commentaire