<el-form-item>
<el-date-picker v-model="query.cycle" type="week" placeholder="选择周" format="yyyy 第 WW 周"
:picker-options="{ firstDayOfWeek: 1 }" @change="weekChange">
</el-date-picker>
</el-form-item>
利用Moment.js
weekChange(val) {
let weekOfDay = moment(val).format("E");
let lastMonday = moment(val).subtract(weekOfDay - 1, "days").format("YYYY-MM-DD");//周一日期
let lastTuesday = moment(val).subtract(weekOfDay - 2, "days").format("YYYY-MM-DD");//周二日期
let lastWedday = moment(val).subtract(weekOfDay - 3, "days").format("YYYY-MM-DD");//周三日期
let lastThurday = moment(val).subtract(weekOfDay - 4, "days").format("YYYY-MM-DD");//周四日期
let lastFriday = moment(val).subtract(weekOfDay - 5, "days").format("YYYY-MM-DD");//周五日期
let year = moment(val).utcOffset("+08:00").format('yyyy') //年
let week = moment(val).utcOffset("+08:00").format('WW') //周
console.log(lastMonday, lastTuesday, lastWedday, lastThurday, lastFriday, year, week);
},
打印如下:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)