const disDuplicate = (oldList, newList, field) => { let list = [], tempObj = {}, allList = [] allList = allList.concat(oldList, newList) for (let i = 0, len = allList.length; i < len; i++) { let item = allList[i] // 判断是否已有相同字段的值 if (!tempObj[item[field]]) { list.push(item) tempObj[item[field]] = 1 } else { // 替换已有相同字段的数据,取最新值 for (let j = 0, jlen = list.length; j < jlen; j++) { if (list[j][field] == item[field]) { list[j] = item break } } } } return list }