[Vuejs]-Checkbox automatically checked all when assigned non-empty variable to v-model

0👍

Your data.repeatOn should define with unique name at HTML like

<input type="checkbox" id="1" value="1" v-model="data.repeatOn[1]" :checked="data.repeatOn.includes('1')"><label for="1">Monday</label>&nbsp;&nbsp;
<input type="checkbox" id="2" value="2" v-model="data.repeatOn[2]" :checked="data.repeatOn.includes('2')"><label for="2">Tuesday</label>&nbsp;&nbsp;
//... data.repeatOn[n]

and at data

data() {
  return {
    data : {
      repeatOn : []
   }
  }
},

Leave a comment