// 今天
jintia(){
let data = new Date()
this.date_stamp = this.convertToDate(data)
console.log(this.date_stamp);
},
// 上一天
shangyitia(){
//前一天
let odata = new Date(
new Date(this.date_stamp).getTime() - 24 * 60 * 60 * 1000
); //计算当前日期 -1
this.date_stamp = this.convertToDate(odata); //格式化日期并赋值
console.log(this.date_stamp);
},
// 下一天
xiayitia(){
//后一天
let odata = new Date(
new Date(this.date_stamp).getTime() + 24 * 60 * 60 * 1000
); //计算当前日期 +1
this.date_stamp = this.convertToDate(odata); //格式化日期并赋值
console.log(this.date_stamp);
},
// 转换日期
convertToDate(date) {
var date = new Date(date);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
m = m < 10 ? "0" + m : m; //月小于10,加0
d = d < 10 ? "0" + d : d; //day小于10,加0
return y + "-" + m + "-" + d;
}