vue实现全选反选

mac2025-08-01  3

<input type="checkbox" v-model="nids" :value="news.nid"/>{{news.nid}} <input type="checkbox" v-on:click="checkAll()"> 全选 checkAll:function(){ // alert(3); var _this=this; this.newsMessage.forEach(function (item,index) { //alert(1); if(_this.nids.indexOf(item.nid)==-1){//判断某元素存在于数组中 _this.nids.push(item.nid); }else {//存在则移除 var ukey = _this.nids.indexOf(item.nid); _this.nids.splice(ukey,1); } }) },
最新回复(0)