数组去重

数组去重:

if(this.cardL.length < 1) {
    this.cardL = res.data.couponList
} else {
    this.cardL = this.cardL.concat(res.data.couponList)
     let temp = []; //一个新的临时数组
    this.cardL.forEach((vt, i) => {
         let No = temp.findIndex(vj => vj.couponId === vt.couponId)
        if(No < 0 ){
            temp.push(this.cardL[i]);
        }
        // if (this.cardL.length - 1 === i) this.cardL = temp
    });
    this.cardL = temp
}

你可能感兴趣的:(数组去重)