Vue(十四):解决ElementUI周选择器标签属性format和value-format冲突问题,并获取年周和日期范围
data(){
return{
week: '',
startDate: '',
endDate: ''
}
}
handleWeekChange(val){
let date = `${new Date(val).getFullYear()}-${new Date(val).getMonth() + 1}-${new Date(val).getDate()}`;
let firstTime = new Date(date).getTime() - 24 * 60 * 60 * 1000;
this.startDate = `${new Date(firstTime).getFullYear()}-${new Date(firstTime).getMonth() + 1}-${new Date(firstTime).getDate()}`;
console.log(this.startDate); // 开始时间
let lastTime = new Date(date).getTime() + 5 * 24 * 60 * 60 * 1000;
this.endDate = `${new Date(lastTime).getFullYear()}-${new Date(lastTime).getMonth() + 1}-${new Date(lastTime).getDate()}`;
console.log(this.endDate); // 结束时间
let year = require("moment")(val).utcOffset("+08:00").format("yyyy");
let week = require("moment")(val).utcOffset("+08:00").format("WW");
console.log(year, week); // 年-周
},