最近在写一个 家政预约系统 里面需要实现下图这样的效果 那就直接上代码
var arr = []
for (let i = 0; i < 7; i++) {
var now = new Date();
//24 * 3600 * 1000 就是计算一天的时间
var date = new Date(now.getTime() + i * 24 * 3600 * 1000);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
let da = year + "-" + month + "-" + day
let data = month + "月" + day + '日'
var weekArray = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
var week = weekArray[new Date(da).getDay()];
var order = {
name: '',
data: ''
}
order.name = week
order.data = data
this.dateList.push(da)
arr.push(order)
}
this.orderData = arr
里面的this这个自己要定义的哦