Vue 复选框全选/反选 配合ajax删除 Springboot

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>
vue部分
发布了42 篇原创文章 · 获赞 73 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_34037264/article/details/102857106
今日推荐