标签:turn == reac console class name push tin com
如Elemgnt的table绑定的数据要某个key是唯一的
var myarry = [ {name: ‘liuyang‘,age :13}, {name:‘jike‘,age:15}, {name:‘liuyang‘,age:223 }, {name:‘jike‘,age:42}, {name:‘ligongjiu‘,age:22} ] // 传入数组(表格的table)和表格的key如name function deweight (arr, key) { let ret = [] arr.forEach((item, index, self) => { let compare = [] ret.forEach((retitem, retindex, retself) => { compare.push(retitem[key]) }) if (compare.indexOf(item[key]) === -1) { ret.push(item) } }) return ret } var result = deweight(myarry,‘name‘) console.log(result)
结果:
[ { name: ‘liuyang‘, age: 13 },
{ name: ‘jike‘, age: 15 },
{ name: ‘ligongjiu‘, age: 22 } ]
标签:turn == reac console class name push tin com
原文地址:https://www.cnblogs.com/jack-liu6/p/8967680.html