Vue
HTML
<div id="app">
<div>
<label>
father
<input type="checkbox" v-model="father" @input="father=true">
</label>
</div>
<div>
<label v-for="(child, i) in children" :key="i">
child {{i}}
<input type="checkbox" v-model="children[i]">
</label>
</div>
<div>
<span> father = {{father}} child = {{ children }} </span>
</div>
</div>
Vue
new Vue({
el: "#app",
data: {
children: [
false,
false,
false,
false
]
},
computed: {
father: {
get() {
return this.children.every(x => x)
},
set(value) {
for (let i = 0; i < this.children.length; i++) {
this.$set(this.children, i, value)
}
}
}
}
})