Javascript TypeError:无法读取属性';视图';未定义的[FullCalendar React]*已解决
嘿,我正试图通过模式表单添加事件,但当我提交它时,会出现此错误:Javascript TypeError:无法读取属性';视图';未定义的[FullCalendar React]*已解决,javascript,reactjs,fullcalendar,frontend,Javascript,Reactjs,Fullcalendar,Frontend,嘿,我正试图通过模式表单添加事件,但当我提交它时,会出现此错误: 我在react中做了一个食谱调度程序,我在上面使用了fullCalendar,我使用了开发人员提供的代码,它使用命令“提示符”请求标题,然后它创建了事件,所以我尝试添加了一个表单,我被这个错误卡住了: 功能代码 handleDateSelect = () => { this.setModalState(true); } formHandler = (e, formField, selectInfo) =&
我在react中做了一个食谱调度程序,我在上面使用了fullCalendar,我使用了开发人员提供的代码,它使用命令“提示符”请求标题,然后它创建了事件,所以我尝试添加了一个表单,我被这个错误卡住了: 功能代码
handleDateSelect = () => {
this.setModalState(true);
}
formHandler = (e, formField, selectInfo) => {
e.preventDefault();
let title = this.state.formField.title;
console.log(title);
let calendarApi = selectInfo.view.calendar;
calendarApi.unselect(); // clear date selection
if (title) {
console.log(title);
calendarApi.addEvent({
id: createEventId(),
title,
start: selectInfo.startStr,
end: selectInfo.endStr,
allDay: selectInfo.allDay,
});
this.setAlert2State(true);
}
}
和模式代码:
<Modal
show={this.state.modalShow}
onHide={() => this.setModalState(false)}
centered
>
<Modal.Header closeButton>
<div>
<h1 className="logText">Entre na sua conta</h1>
</div>
</Modal.Header>
<Modal.Body>
<Form
method="POST"
onSubmit={(e) => this.formHandler(e, this.state.formField)}
>
<FormGroup>
<Label for="title">Nome da receita</Label>
<Input
type="text"
name="title"
id="title"
onChange={(e) => this.inputChangeHandler(e)}
value={this.state.formField.title}
required
/>
</FormGroup>
<Button type="submit" color="success">
Entrar
</Button>
</Form>
</Modal.Body>
</Modal>
<FullCalendar
locale={ptLocale}
editable={true}
headerToolbar={{
left: "",
center: "title",
right: "prev,next today",
}}
initialEvents={INITIAL_EVENTS}
select={this.handleDateSelect}
eventClick={this.handleEventClick}
eventsSet={this.handleEvents}
schedulerLicenseKey="CC-Attribution-NonCommercial-NoDerivatives"
initialView="dayGridMonth"
themeSystem="bootstrap"
selectMirror={true}
dayMaxEvents={true}
selectable={true}
droppable={true}
plugins={[
listPlugin,
bootstrapPlugin,
resourceTimelinePlugin,
dayGridPlugin,
interactionPlugin,
]}
/>
this.setModalState(false)}
居中的
>
康塔街
this.formHandler(e,this.state.formField)}
>
诺梅达雷西塔酒店
this.inputChangeHandler(e)}
值={this.state.formField.title}
必修的
/>
诱捕者
fullcalendar:
<Modal
show={this.state.modalShow}
onHide={() => this.setModalState(false)}
centered
>
<Modal.Header closeButton>
<div>
<h1 className="logText">Entre na sua conta</h1>
</div>
</Modal.Header>
<Modal.Body>
<Form
method="POST"
onSubmit={(e) => this.formHandler(e, this.state.formField)}
>
<FormGroup>
<Label for="title">Nome da receita</Label>
<Input
type="text"
name="title"
id="title"
onChange={(e) => this.inputChangeHandler(e)}
value={this.state.formField.title}
required
/>
</FormGroup>
<Button type="submit" color="success">
Entrar
</Button>
</Form>
</Modal.Body>
</Modal>
<FullCalendar
locale={ptLocale}
editable={true}
headerToolbar={{
left: "",
center: "title",
right: "prev,next today",
}}
initialEvents={INITIAL_EVENTS}
select={this.handleDateSelect}
eventClick={this.handleEventClick}
eventsSet={this.handleEvents}
schedulerLicenseKey="CC-Attribution-NonCommercial-NoDerivatives"
initialView="dayGridMonth"
themeSystem="bootstrap"
selectMirror={true}
dayMaxEvents={true}
selectable={true}
droppable={true}
plugins={[
listPlugin,
bootstrapPlugin,
resourceTimelinePlugin,
dayGridPlugin,
interactionPlugin,
]}
/>
在我看来,
selectInfo
在这一行中返回为undefined
let calendarApi = selectInfo.view.calendar;
更有趣的是,formHandler
signature接收3个参数,其中第3个参数是selectInfo
,即undefined
formHandler = (e, formField, selectInfo) => {
然而,当您调用它时,您只传递了2个参数
onSubmit={(e) => this.formHandler(e, this.state.formField)}
问题是,您没有传递参数在我看来,
selectInfo
在这行中返回为undefined
let calendarApi = selectInfo.view.calendar;
更有趣的是,formHandler
signature接收3个参数,其中第3个参数是selectInfo
,即undefined
formHandler = (e, formField, selectInfo) => {
然而,当您调用它时,您只传递了2个参数
onSubmit={(e) => this.formHandler(e, this.state.formField)}
问题是,您没有传递参数此方法需要三个参数:
formHandler = (e, formField, selectInfo) => { ...
但你只提供了两个:
onSubmit={(e) => this.formHandler(e, this.state.formField)}
因此,此行失败,因为selectInfo未定义:
let calendarApi = selectInfo.view.calendar;
此方法需要三个参数:
formHandler = (e, formField, selectInfo) => { ...
但你只提供了两个:
onSubmit={(e) => this.formHandler(e, this.state.formField)}
因此,此行失败,因为selectInfo未定义:
let calendarApi = selectInfo.view.calendar;
嘿,谢谢你的帮助,我现在正在传递3个参数,但它给了我:第179:59行:“selectInfo”没有定义。没有定义this.formHandler(e,this.state.formField,selectInfo)}>@EusébioSilva,即使你写
this.formHandler(e,this.state.formField,selectInfo)
,您希望selectInfo
的值在该上下文中来自何处?它似乎没有源代码。嘿,谢谢你的帮助,我现在正在传递3个参数,但它给了我:第179:59行:“selectInfo”没有定义。没有定义this.formHandler(e,this.state.formField,selectInfo)}>@EusébioSilva,即使你写this.formHandler(e,this.state.formField,selectInfo)
,您希望在该上下文中,selectInfo
的值来自哪里?它似乎没有源代码。嘿,谢谢你的帮助,我现在正在传递3个参数,但它给了我:第179:59行:“selectInfo”没有定义。formHandler(e,this.state.formField,selectInfo)}>错误非常清楚。您正在调用一个未定义的变量。嘿,谢谢您的帮助,我现在正在传递3个参数,但它给了我:第179:59行:“selectInfo”未定义。没有未定义此变量。formHandler(e,this.state.formField,selectInfo)}>错误非常清楚。您正在调用一个未定义的变量。