先上效果图
<a-calendar @panelChange="handlePanelChange">
</a-calendar>
handlePanelChange(value) {
const { firstDate, lastDate } = this.getFirstDateAndLastDateOnThePanel(value)
console.log(firstDate, lastDate)
},
// 获取面板第一个日期和最后一个日期
getFirstDateAndLastDateOnThePanel(date) {
const firstDate = moment(date).startOf('month')
const lastDate = moment(date).endOf('month')
const firstDateDay = firstDate.day()
firstDate.subtract(firstDateDay, 'days')
lastDate.add(42 - Number(lastDate.format('DD')) - firstDateDay, 'days')
return {
firstDate: firstDate.format('YYYY-MM-DD'),
lastDate: lastDate.format('YYYY-MM-DD'),
}
},
tips: 于 此处转载