some的用法
list:[
{id:1,name:'奔驰',citme:new Date()},
{id:2,name:'宝马',citme:new Date()}
]
- // this.list.some((item,i)=>{
// if(item.id==id){
// this.list.splice(i,1)
// return true
// }
// })
其中some是比较list中每一项的id值,然后把这个id值给了item,item.id就代表了list中的每一项id值,如果返回true,就不再往后执行
var index= this.list.findIndex(item=>{
if(item.id==id){
return true
}
})