let data = [{date: '3.15', step: 1500}, {date: '3.18', step: 3800}, {date: '3.20', step: 8000}];
dealParams(data);
function dealParams(params) {
let key = 0, list = {date:[], steps:[]}, day = '';
for(let i = 1; i <= 31; i++) {
list.steps[i-1] = 0;
if(key < params.length){
day = new Date(params[key].date).getDate();
}
if( i === day) {
list.stpes[i-1] = params[key].step;
key++;
}
list.date.push(i)
}
}
添加回答
举报
0/150
提交
取消