我使用 的完整日历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);
}
}
Run Code Online (Sandbox Code Playgroud)
//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!');
}, …Run Code Online (Sandbox Code Playgroud)