new Date()
data(){
return{
ylabel:[],
xlabel:[],
}
},
getdate(){
var n = 7; //获取最近七天的日期
var date = new Date();
console.log(date)
for(var i=0;i<n;i++){
date.setDate(date.getDate()-1)
var year = date.getFullYear(); // 返回的是年份
var month = date.getMonth() + 1; // 返回的月份上个月的月份,记得+1才是当月
var dates = date.getDate(); // 返回的是几号
this.ylabel.push(month+"/"+dates)
}
console.log(this.ylabel);
// var day = date.getDay(); // 周一返回的是1,周六是6,但是周日是0
// var arr = [ "星期日","星期一","星期二","星期三","星期四","星期五","星期六",];
// console.log("今天是" + year + "年" + month + "月" + dates + "日" + arr[day]);
},
```