current function
const index1 = JSON.stringify(this.selectGame).indexOf(JSON.stringify(item1));
this.selectGameitem1
previous function
//
check_show(item1) {
const index1 = this.selectGame.indexOf(item1);
// let aa = { idName:item.Id,nameId:item.Name}
if(index1 > -1 ){
this.selectGame.splice(index1, 1)
}else if(this.selectGame.length < 10){
this.selectGame.push(item1);
}
},
the above function is in this.selectGame.push (item1); the element added in the execution is valid. If the selectGame already contains the element in the middle, it won"t work, so I use JSON.stringify to convert the item1 into a string, but the problem is that the result from indexOf is the length of the string, such as 317, index1, 175, 818, 2500, etc., you can"t use this.selectGame.splice (index1, 1) to delete the included functions by position
.