dataformat(arr) {
var newArr = [];
arr.forEach((address, i) => {
let index = 0;
let alreadyExists = newArr.some((newAddress, j) => {
if (address.createTime.substring(0,10) == newAddress.time.substring(0,10)) {
index = j;
return true;
}
});
if (!alreadyExists) {
newArr.push({
time: address.createTime.substring(0,10),
items:[address]
});
} else {
newArr[index].items.push(address);
}
});
this.allList = newArr;
}
效果图 。
后台返回的数据,
格式化以后的数据