splice 删除数组中符合条件的一项

关注公众号【Miles】查看更多技术文档

lg:1


if (this.addArr.find(addItem =>addItem === doctor.id)) {

          this.addArr.splice(this.addArr.findIndex(

            addItemId => addItemId === doctor.id),1

          )

         } else {

           this.delArr.push(doctor.id)

         }

lg:2


const arr =  this.addForm.estates

arr.splice(arr.findIndex(v => v.index === item.index), 1)

json数组去重

const strings = list.map((item) => JSON.stringify(item));
const removeDupList = [...new Set(strings)]; //也可以使用Array.from(new Set(strings))
const result = removeDupList.map((item) => JSON.parse(item))

你可能感兴趣的:(splice 删除数组中符合条件的一项)