记录一次数组相同筛选
subList(){
let data = [{
time:"2020-03-14",
name:"maomao"
},
{
time:"2020-03-14",
name:"maomao"
},
{
time:"2020-03-15",
name:"maomao"
},
{
time:"2020-03-15",
name:"maomao"
},
{
time:"2020-03-16",
name:"maomao"
},
{
time:"2020-03-16",
name:"maomao"
},
{
time:"2020-03-16",
name:"maomao"
},]
var m = new Map()
data.forEach(ele=>{
if(m.has(ele.time)){
let tempArray = m.get(ele.time);
tempArray.push(ele);
m.set(ele.time,tempArray)
}else{
let tempArray = [];
tempArray.push(ele);
m.set(ele.time,tempArray)
}
})
console.log(m)
}
相互学习!加油