Vue 复选框全选 配合ajax删除 Springboot
这是Vue全选代码
checkedAll: function() {
var _this = this;
//遍历数组列表
this.newss.forEach(function(ns, index) {
if(_this.nids.indexOf(ns.nid)==-1){//判断某元素是否存在于数组中
//默认选中的数组
_this.nids.push(ns.nid);
}else{//存在则移除
var nkey = _this.nids.indexOf(ns.nid);
_this.nids.splice(nkey,1);
}
});
},
html部分代码
<td style="text-align:left; padding:19px 0;padding-left:20px;">
<input type="checkbox" v-model='checked' v-on:click='checkedAll'> 全选
</td>