标签:menu var 排序 obj for nav lis this 调用
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‘])
标签:menu var 排序 obj for nav lis this 调用
原文地址:https://www.cnblogs.com/dmwcq/p/9717322.html