vue 最简单的方法实现全选反选

就下面几步,简单实现!

 <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;
        })
  }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章