去重
2020-09-11 本文已影响0人
PYFang
图片上传 检测是否重复再上传
this.selectedValue.forEach((val) => {
let auctionCompanyTemp = {}
auctionCompanyTemp.companyCode = this.options2.filter(
(vo) => vo.companyCode == val
)[0].companyCode
auctionCompanyTemp.companyName = this.options2.filter(
(vo) => vo.companyCode == val
)[0].companyName
!this.companyJson.some(
(item) => item.companyCode === auctionCompanyTemp.companyCode
) && this.companyJson.push(auctionCompanyTemp)
})
基本去重
unique(arr) {
const res = new Map()
return arr.filter((arr) => !res.has(arr.xxx) && res.set(arr.xxx, 1))
}
console.log(this.unique(response.DataList))