vue中使用some删除list中的数据

在vue中可以使用some方法查找需要删除的所以

this.list.some((item, i) => {
    if (item.id == id) {
        this.list.splice(i, 1)
        return true;
    }
})

也可使用findIndex方法

var index = this.list.findIndex(item => {
    if (item.id == id){
        return true;
    }
})
 
this.list.splice(index, 1)
posted @ 2021-07-09 17:11  岁月淡忘了谁  阅读(1498)  评论(0编辑  收藏  举报