使用findIndex找到数据位置后使用splice将其裁切。
arr.splice(arr.findIndex(item => item.id=== 1), 1)
filter方法:创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所有元素
this.list = this.list.filter((item) => {
return item.id != id
});
使用findIndex找到数据位置后使用splice将其裁切。
arr.splice(arr.findIndex(item => item.id=== 1), 1)
filter方法:创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所有元素
this.list = this.list.filter((item) => {
return item.id != id
});