最近七天时间组成的数组(不包含当天)
const arr=[]
for (let i = 0; i < 7; i++) {
const time = new Date(new Date().setDate(new Date().getDate() + i - 7));
const year = time.getFullYear();
const month = `0${time.getMonth() + 1}`.slice(-2);
const strDate = `0${time.getDate()}`.slice(-2);
arr.push(`${year}-${month}-${strDate}`);
}
指定长度的随机数组成的数组
let arr = [];
for (let i = 0; i < length; i++) {-----length:随机数组的长度
var random = Math.floor(Math.random() * 100);
arr.push(random);
}