【发布时间】:2021-05-23 15:35:07
【问题描述】:
我正在使用 FullCalendar 在我的应用程序中实例化一个日历,即使我可以在我的网页上看到日历,我也无法执行 fullCalendar() 函数。它给了我一个 TypeError 说 jquery.js:4050 jQuery.Deferred exception: calendarEl.fullCalendar is not a function TypeError: calendarEl.fullCalendar is not a function
代码如下:
'use strict';
import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlugin from '@fullcalendar/timegrid';
import 'fullcalendar';
export default class CalendarDisplay {
constructor() {
this.name = 'CalendarDisplay';
console.log('CalendarDisplay');
var calendarEl = document.getElementById('calendar');
let calendar = new Calendar(calendarEl, {
plugins: [dayGridPlugin,timeGridPlugin],
initialView: "timeGridWeek",
headerToolbar : {
left: 'prev,next',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
allDaySlot: false,
slotEventOverlap: false,
scrollTime: '08:00:00',
events: [
{
title: 'All Day Event',
start: '2021-05-24',
},
{
title: 'Long Event',
start: '2021-05-24T09:00:00',
end: '2021-05-24T24:00:00'
}
]
});
calendar.render();
calendarEl.fullCalendar({
viewRender: function(view, element) {
console.log("The view's title is " + view.intervalStart.format());
console.log("The view's title is " + view.name);
}
});
}
}
【问题讨论】:
-
fullCalendar 必须在日历上而不是在 calendarEl 上完成,不是吗?
-
@DonKnacki 如果我在日历上这样做,它仍然会给出同样的错误
jQuery.Deferred exception: calendar.fullCalendar is not a function TypeError: calendar.fullCalendar is not a function -
是的,对不起,我不知道这个库,但经过一番搜索,它似乎是一个你必须实例化的类:fullcalendar.io/docs/initialize-globals
-
@DonKnacki 在我的情况下不起作用,它给出一个错误,说 fullCalendar 没有定义
-
@IanBell 下面的答案对您有用吗?
标签: javascript fullcalendar fullcalendar-5