objkey(obj, keys){ //對象數組排序
var n = keys.length,
key = []
while(n--){
key.push(obj[keys[n]])
}
return key.join('|')
},
uniqeByKeys(array,keys){
var arr = []
var hash = {}
for (var i = 0, j = array.length; i < j; i++) {
var k = this.objkey(array[i], keys)
console.log(k)
if (!(k in hash)) {
hash[k] = true
arr .push(array[i])
}
}
return arr
},
调用 let newList = this.uniqeByKeys(navMenu,['id'])