在table列表中通过按钮移除某条数据

需求:前提是table展示list数组的全部数据,要求移除操作后,在list数组中删除该条数据。

//移除方法
deleteBatch(elecId) {
  console.log(this.valList, 'valList1'); //移除前数组
  this.valList.forEach((value, index, array) => {
    if (value.elecId == elecId) {  //判断条件
      array.splice(index, 1) //删除符合条件的数据
    }
  })
  console.log(this.valList, 'valList2'); //移除后数组
},

评论

暂无评论