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

 

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