vue获取近七天的起始日和结束日
例如:startDate: 2023-07-29 endDate: 2023-08-04
data() {
return {
startDate: null,
endDate: null
}
},
mounted() {
this.calculateDateRange();
},
methods: {
calculateDateRange() {
var currentDate = new Date();
var startDate = new Date();
startDate.setDate(currentDate.getDate() - 6);
this.startDate = this.formatDate(startDate);
this.endDate = this.formatDate(currentDate);
console.log(this.startDate,'2023-07-29')
console.log(this.startDate,'2023-08-04')
},
formatDate(date) {
var year = date.getFullYear();
var month