// uniapp -原生复选框-解决点击复选框卡顿现象 --- 供PO越库 入库越库按钮用途 export default { data() { return { arrIds: [], }; }, watch: { // 监听复选框 arrIds(newVal, oldVal) { console.log("newVal----" + newVal); console.log("oldVal----" + oldVal); if (newVal.length < oldVal.length) { for (var i = 0, lenI = oldVal.length; i < lenI; ++i) { const item = oldVal[i]; if (!newVal.includes(item)) { console.log("取消了一个--------" + item); // this.handleCart(0, item); } } } else { for (var i = 0, lenI = newVal.length; i < lenI; ++i) { const item = newVal[i]; if (!oldVal.includes(item)) { console.log("选中了一个--------" + item); // this.handleCart(1, item); } } } }, }, methods: { // 选中复选框 checkboxChange: function (e) { var values = e.detail.value; //存放所有选中的id this.arrIds = values; }, // 根据选中的key,更新提交的列表 handleCart(type, itemHandle) { console.log(itemHandle); if (type == 1) { //选中 let idx = this.singlist.findIndex((v) => v.key == itemHandle); if (idx > -1) { let idx3 = this.arr.findIndex((v) => v.key == itemHandle); if (idx3 == -1) { this.arr.push(this.singlist[idx]); } } } if (type == 0) { //取消 let idx2 = this.arr.findIndex((v) => v.key == itemHandle); if (idx2 > -1) { this.arr.splice(idx2, 1); } } }, }, };