1. HTML section

<input id="all" type="checkbox" @click="checkAll($event)"> <input class="checkItem" type="checkbox" value="'+row.id+'" />// the value of the primary key id is the value of the loop dynamically rendered dataCopy the code

2. Js part

CheckData :[], // bind event $(".checkitem "). Click (function (e) {var thats = $(this); if (e.target.checked){ VueObj.checkData.push(thats.val()); }else { VueObj.checkData.splice(VueObj.checkData.indexOf(thats.val()),1); }}); Function (e) {var checkObj = $('. CheckItem '); if (e.target.checked){ for (var i=0; i< checkObj.length; i++){ this.checkData.push(checkObj[i].value); } }else { this.checkData = []; } console.log(VueObj.checkData); Function (val,oldVal) {var checkObj = $('. CheckItem '); for (var i = 0; i < checkObj.length; i++){ if ($.inArray(checkObj[i].value,val) >= 0){ checkObj[i].checked = true; }else { checkObj[i].checked = false; }}}}Copy the code