var time = obj.biz_date + ' ' + obj.hours;
//查找数组中的重复值
function find_first(arr, callback) {
var val;
arr.forEach((elt, i, arry) =>{
if(callback(elt)){
val = elt;
}
});
return val;
}
var val = find_first(vm.displays, (elt) => elt.time == time);
if(val) {
val [obj.age_group] = obj.times;
} else{
var objdata = {
time:time
}
objdata[obj.age_group] = obj.times;
vm.displays.push(objdata);
}
var val;
arr.forEach((elt, i, arry) =>{
if(callback(elt)){
val = elt;
}
});
return val;
}
var val = find_first(vm.displays, (elt) => elt.time == time);
这段代码就是查找数组中重复值所在的那个对象