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

2021-09-06  本文已影响0人  郭先森啊
关注公众号【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))
上一篇下一篇

猜你喜欢

热点阅读