Angular15集成FullCalendar报错:registerPlugins不存在于FullCalendarModule
解决FullCalendar Angular 15中
registerPlugins不存在的错误 错误原因
FullCalendar v6版本对Angular集成的API做了调整,FullCalendarModule不再提供registerPlugins静态方法,原有的插件注册方式已被废弃。
具体修复步骤
- 删除代码中这段无效的注册代码:
FullCalendarModule.registerPlugins([ // register FullCalendar plugins dayGridPlugin, interactionPlugin, ]);
- 在模块的
imports数组中,将FullCalendarModule替换为FullCalendarModule.forRoot()方法,并在配置参数中传入插件数组:
修改后的完整模块代码:
import { NgModule } from "@angular/core"; import { CommonModule } from "@angular/common"; import { TakvimRoutingModule } from "./takvim-routing.module"; import { FormsModule } from "@angular/forms"; import { NgbModule } from "@ng-bootstrap/ng-bootstrap"; import { SweetAlert2Module } from "@sweetalert2/ngx-sweetalert2"; import { TableModule } from "primeng/table"; import { ButtonModule } from "primeng/button"; import { NgSelectModule } from "@ng-select/ng-select"; import { TakvimComponent } from "./takvim.component"; import { FullCalendarModule } from "@fullcalendar/angular"; import dayGridPlugin from "@fullcalendar/daygrid"; import interactionPlugin from "@fullcalendar/interaction"; import { PerfectScrollbarModule } from "ngx-perfect-scrollbar"; import { CalendarModule } from "primeng/calendar"; @NgModule({ declarations: [TakvimComponent], imports: [ CommonModule, TakvimRoutingModule, FormsModule, NgbModule, PerfectScrollbarModule, FeahterIconModule, CalendarModule, SweetAlert2Module.forChild(), TableModule, ButtonModule, NgSelectModule, // 改用forRoot方法注册插件 FullCalendarModule.forRoot({ plugins: [dayGridPlugin, interactionPlugin] }) ], }) export class TakvimModule {}
补充说明
这种方式是FullCalendar v6官方推荐的Angular插件注册方案,通过forRoot()方法一次性完成模块导入和插件配置,同时也符合Angular的模块初始化规范。
内容的提问来源于stack exchange,提问作者hasancali
相关产品推荐
相关产品推荐

