// 数组去重
removeDuplicats(arr, type) {
if (arr.length == 0) {
return arr
} else {
if (type) {
var obj = {}
var newArr = arr.reduce((cur, next) => {
obj[next[type]] ? '' : (obj[next[type]] = true && cur.push(next))
return cur
}, [])
return newArr
} else {
return Array.from(new Set(arr))
}
}
},
使用:
this.selectUserList = this.removeDuplicats(
this.selectUserList, // 去重的数组
'USERID' // 根据这个USERID去重
)