如果我想在React js或简单的Javascript中使用这段代码,下面的代码有什么替代解决方案?var startDate=$('#calendar'(.fullCalendar('getView'(.intervalStart.format('DD/MM/YYYY'(;var endDate=$('#calendar'(.fullCalendar('getView'(.intervalEnd.format('DD/MM/YYYY'(;
希望它能起作用
<FullCalendar
datesSet={(arg) => {
console.log(arg.start) //starting visible date
console.log(arg.end) //ending visible date
}}
/>
您可以使用datesRender
道具来获取活动月份范围。
<FullCalendar
datesRender={(arg) => {
console.log(arg.view.activeStart) //starting visible date
console.log(arg.view.activeEnd) //ending visible date
}}
/>
获取当前月份,其中一月=1,十二月=12
const getCurrentMonth = (arg) => {
const startDate = arg.view.activeStart
if (arg.view.type === 'dayGridMonth'){
console.log('Current Month', startDate.getMonth() + 1 )
return
}
if( arg.view.type === 'dayGridDay'){
startDate.setDate(startDate.getDate() + 8)
console.log('Current Month', startDate.getMonth() + 1 )
}
}
<FullCalendar
datesRender={(arg) => getCurrentMonth(arg)}
/>