我使用 的完整日历primereact
,但我需要选择特定的年份和月份。为此,我有单独的日期选择器。但是当我尝试使用gotoDate
完整日历的方法更改日期时,
有错误
'未捕获的类型错误:无法读取 null 的属性'onViewDateChange''
//method on datepicker change
handleChange(date) {
console.log(date);
this.setState({
startDate: date.value,
});
const calendarEl = document.getElementById('fullCalendar');
const calendar = new Calendar(calendarEl);
calendar.gotoDate(date.value);
// calendar.gotoDate(this.state.startDate);
}
}
//datepicker
<Calendar view="month" dateFormat="mm/yy" value={startDate} onChange={this.handleChange} yearNavigator yearRange="2015:2030"/>
//calendar
<FullCalendar
id="fullCalendar"
firstDay={1}
defaultView={`${CalendarRepo()
.isCalendarModelMonth(model) === 'month' ? 'dayGridMonth' : 'timeGridWeek'}`}
header={{
left: 'prev,next today, custom',
center: 'title',
right: 'dayGridMonth,timeGridWeek',
}}
customButtons={{
custom: {
text: 'custom 1',
click() {
calendar.gotoDate();
alert('clicked custom button 1!');
},
},
}}
nowIndicator
displayEventEnd={{
month: false,
basicWeek: true,
default: false,
}}
businessHours
timeZone="Europe/Kiev"
selectable
rerenderDelay={10}
eventDurationEditable
editable
droppable
eventDrop={(info) => {
this.handleDragEvent(info.event.id, info.event.title, info.event.start, info.event.end, info.event.allDay);
}}
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin, bootstrapPlugin, momentTimezonePlugin]}
themeSystem="bootstrap"
events={model.events}
eventReceive={this.eventReceive}
eventClick={this.handleEventClick}
dateClick={this.handleDateClick}
eventLimit
/>