//filter de return 当数据匹配时再付给集合 ,查询筛选 return this.list.filter((item) => { //string.includes() 判断数据是否包含 if (item.name.includes(keywords)) { return item } })
return this.list.filter(function(item){ //string.includes() 判断数据是否包含 if (item.name.includes(keywords)) { return item } })
--------------------------------------------
//删除,用some时,判断要删除的数据return true 集合不在往下执行 var index = this.list.some(function (item, i) { if (item == id) { return true; } }); /* var index = this.list.findIndex(item => { if (item.id == id) { return true; } })*/ //得到要是删除的索引,移除 this.list.splice(index, 1)