React TypeError 中的完整日历:无法读取未定义的属性“日历”

尝试在状态中存储有关选定时间的信息时出现错误。感谢您的帮助,感谢您的宝贵时间!如果你们需要更多具体信息,请告诉我。


以下是我的组件中的代码片段:


  const Calendar = (props) => {


  const [startTime, setStartTime] = React.useState('');


  const handleSelect = (selectedInfo) => {

    //alert(selectedInfo.startStr);

    setStartTime(selectedInfo.startStr);

  }


  return (

    <FullCalendar 

      defaultView="timeGridWeek" 

      weekends={false} 

      allDaySlot={false}

      plugins={[ timeGridPlugin, dayGridPlugin, interactionPlugin ]} 

      minTime="08:00:00"

      selectable={true}

      selectMirror={true}

      selectOverlap={false}

      select={handleSelect}

      header={{

        left: 'prev,next today',

        center: 'title',

        right: 'dayGridMonth,timeGridWeek,timeGridDay'

      }}

      events={[

        { title: 'event 1', start: '2020-03-16 10:00:00', end: '2020-03-16 12:00:00' },

        { title: 'event 2', start: '2020-03-19' }

      ]}

    />

  );

}


当年话下
浏览 124回答 2
2回答

慕妹3242003

升级fullcalendar和fullcalendar-react版本4.4.1为我解决了这个问题。看来这是一个错误。

一只名叫tom的猫

export default class Calendar extends React.Component{&nbsp; &nbsp; state = {startTime: ''}&nbsp; &nbsp; handleSelect = (selectedInfo) => {&nbsp; &nbsp; &nbsp; &nbsp; //alert(selectedInfo.startStr)&nbsp; &nbsp; &nbsp; &nbsp; this.setState({ startTime: selectedInfo.startStr})&nbsp; &nbsp; &nbsp; &nbsp; console.log("working!!", this.state.startTime)&nbsp; &nbsp; }&nbsp; &nbsp; render(){&nbsp; &nbsp; &nbsp; &nbsp; return (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <FullCalendar&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; defaultView="dayGridMonth"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; weekends={false}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allDaySlot={false}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plugins={[timeGridPlugin, dayGridPlugin, interactionPlugin]}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minTime="08:00:00"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectable={true}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectMirror={true}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectOverlap={false}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select={this.handleSelect}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header={{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: 'prev,next today',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; center: 'title',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right: 'dayGridMonth,timeGridWeek,timeGridDay'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; events={[&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { title: 'event 1', start: '2020-03-16 10:00:00', end: '2020-03-16 12:00:00' },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { title: 'event 2', start: '2020-03-19' }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; />&nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; &nbsp; }}我也有同样的问题。相同的错误信息。我一直在搜索互联网,我想出的解决方案是这样的
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript