FullCalendar V6(Angular) Timegrid插件:allDaySlot不识别,如何隐藏全天栏?
解决FullCalendar 6.x中allDaySlot参数不被识别的问题
FullCalendar从v6版本开始调整了配置结构,allDaySlot不再是全局CalendarOptions的属性,而是被归类到timegrid插件的专属配置项里,直接全局配置自然会触发TS类型错误。
解决方法很简单,把allDaySlot放到timeGrid配置对象里就行:
import { Component } from '@angular/core'; import { CalendarOptions } from '@fullcalendar/angular'; import timeGridPlugin from '@fullcalendar/timegrid'; @Component({ selector: 'app-calendar', templateUrl: './calendar.component.html', }) export class CalendarComponent { calendarOptions: CalendarOptions = { plugins: [timeGridPlugin], // 其他全局配置项(比如headerToolbar、initialView等) timeGrid: { allDaySlot: false // 在这里配置全天栏的显示/隐藏 } }; }
注意两点:
- 确保
timegrid插件已经在plugins数组里注册(你当前安装的版本已经包含这个插件,只要注册就行) - 不同视图的专属配置都要放到对应插件的配置对象下,比如dayGrid视图的相关配置要放到
dayGrid对象里
内容的提问来源于stack exchange,提问作者Archonite
相关产品推荐
相关产品推荐

