就下面几步,简单实现!
<input type="checkbox" name="quanxuan" id="quanxuan" @click="checkAll">全选
//全选设置一个函数
<div class="lei" v-for="list in 10" :key="list">
<input type="checkbox" ref="che" name="quanxuan" id="quanxuan">
</div>//加上 ref
//函数遍历
methods:{
checkAll(){
this.$refs.che.filter(item=>{
item.checked = !item.checked;
})
}