使用some删除:
1 delete(id){ 2 //根据id找出索引, 3 //如果找到索引直接调用数组splice方法 4 this.list.some((item,i) => { 5 if(item.id==id){ 6 this.list.splice(i,1) 7 return true; 8 } 9 })
使用findIndex:
1 // findIndex直接找出索引,再根据索引删除数据 2 // findIndex只是用来查找索引 3 var index= this.list.findIndex(item =>{ 4 if(item.id==id){ 5 return ture; 6 } 7 this.list.splice(indedx,1) 8 })