废话不多说直接上代码
// 获取明天后天什么日期
GetDateStr(AddCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
},
//获取明天后天星期几
GetDay(addCont) {
let val = new Date().getDay();
let arr = [0, 1, 2, 3, 4, 5, 6];
switch (arr[(val + addCont) % 7]) {
case 0:
return "星期天";
case 1:
return "星期一";
case 2:
return "星期二";
case 3:
return "星期三";
case 4:
return "星期四";
case 5:
return "星期五";
case 6:
return "星期六";
}
},
如果你还不会用,你就看
传入0就是获取到的是今天,1就是明天,以此类推
// 获取日期
getTime() {
let myDate = new Date();
// let val = myDate.toLocaleDateString();
this.date = this.GetDateStr(0);
this.dateTwo = this.GetDateStr(1);
this.dateThree = this.GetDateStr(2);
this.dateFour = this.GetDateStr(3);
this.day = this.GetDay(0);
this.dayTwo = this.GetDay(1);
this.dayThree = this.GetDay(2);
this.dayFour = this.GetDay(3);
},