fullcalendar - 直接进入页面时,Fullcalendar 无法读取未定义的属性破坏
问题描述
我正在使用 Nuxt 2.14.3 并且我想使用fullcalendar 库。为此,我通过 Yarn 添加了以下软件包:
yarn add @fullcalendar/vue
yarn add @fullcalendar/interaction
yarn add @fullcalendar/daygrid
yarn add @fullcalendar/timegrid
yarn add @fullcalendar/list
我的 Vue 模板文件如下所示:
<template>
<client-only placeholder="loading...">
<FullCalendar class="demo-app-calendar" :options="calendarOptions">
<template #eventContent="arg">
<b>{{ arg.timeText }}</b>
<i>{{ arg.event.title }}</i>
</template>
</FullCalendar>
</client-only>
</template>
<script>
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlugin from '@fullcalendar/timegrid'
import interactionPlugin from '@fullcalendar/interaction'
export default {
components: {
FullCalendar,
},
mixins: [
page({
meta() {
return {
title: this.$tU('meta_title_vrm_planning'),
}
},
}),
],
data() {
return {
calendarOptions: {
plugins: [
dayGridPlugin,
timeGridPlugin,
interactionPlugin, // needed for dateClick
],
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay',
},
initialView: 'dayGridMonth',
initialEvents: [
{
id: 1,
title: 'All-day event',
start: new Date().toISOString().replace(/T.*$/, ''),
},
{
id: 2,
title: 'Timed event',
start: `${new Date().toISOString().replace(/T.*$/, '')}T12:00:00`,
},
], // alternatively, use the `events` setting to fetch from a feed
editable: true,
selectable: true,
selectMirror: true,
dayMaxEvents: true,
weekends: true,
select: this.handleDateSelect,
eventClick: this.handleEventClick,
eventsSet: this.handleEvents,
/* you can update a remote database when these fire:
eventAdd:
eventChange:
eventRemove:
*/
},
currentEvents: [],
}
},
methods: {
handleDateSelect(selectInfo) {
const title = prompt('Please enter a new title for your event')
const calendarApi = selectInfo.view.calendar
calendarApi.unselect() // clear date selection
if (title) {
calendarApi.addEvent({
id: 3,
title,
start: selectInfo.startStr,
end: selectInfo.endStr,
allDay: selectInfo.allDay,
})
}
},
handleEventClick(clickInfo) {
if (confirm(`Are you sure you want to delete the event '${clickInfo.event.title}'`)) {
clickInfo.event.remove()
}
},
handleEvents(events) {
this.currentEvents = events
},
},
}
</script>
它给了我以下错误:
[Vue warn]: Error in mounted hook: "TypeError: DateProfileGeneratorClass is not a constructor"
found in
---> <FullCalendar>
和
TypeError: DateProfileGeneratorClass is not a constructor
at buildDateProfileGenerator (main.js?d610:7232)
并且
TypeError: Cannot read property 'destroy' of undefined
at VueComponent.beforeDestroy (FullCalendar.js?ff68:33)
注意:这在从另一个页面访问我的页面时非常有效,但是当直接转到页面 URL 时(或单击 CTRL+F5 时)我收到上述错误。
注意 2:我尝试按照示例 repo https://github.com/fullcalendar/fullcalendar-example-projects/tree/master/nuxt中的建议在 Nuxt 配置中编译库,但它给了我完全相同的错误,但有.ts 文件而不是 .js 文件。
解决方案
推荐阅读
- ios - UITableView separatorStyle = none vs. separatorColor = .clear
- java - 在线程“主”com.telelogic.rhapsody.core.RhapsodyRuntimeException 中获取异常:无法共同创建对象
- audio - 使用 libav (avconv) 或 ffmpeg 进行多通道 AAC mp4 编码
- reactjs - React App登录错误:超过最大更新深度
- api - 扑。小部件测试中的模拟 api 调用
- css - 居中的内容,但主要内容和侧边栏有自己的颜色来扩展屏幕
- php - 所有页面的 Wordpress ACF 真/假条件
- spring - 导入org.springframework.boot.SpringApplication无法解决
- python - 在不使用嵌套循环的情况下查找所有 word2vec 编码对的余弦距离
- java - 在循环中创建对象并添加到列表