javascript - 在尝试导入插件 angular 之前出错 fullcalendar lib
问题描述
我有这个错误:
Error: Please import the top-level fullcalendar lib before attempting to import a plugin.
当我将 resourceTimeGridPlugin 添加到插件时。
我的代码:
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin, { Draggable } from '@fullcalendar/interaction';
import { FullCalendarComponent } from '@fullcalendar/angular';
import timeGridPlugin from '@fullcalendar/timegrid';
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
解决方案
您必须在组件中包含 Calendar Core 对象:
import { Calendar } from '@fullcalendar/core';
在您的构造函数中,您必须添加以下内容:
constructor() {
const name = Calendar.name;
}
完整示例:
import { Component } from '@angular/core';
import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
calendarOptions = {
plugins: [dayGridPlugin],
initialView: 'dayGridMonth'
};
constructor() {
const name = Calendar.name;
}
}
这会在插件需要之前强制加载/初始化核心组件和 VDom 引用。
推荐阅读
- beanstalkd - Beanstalkd - 是否可以暂停一个管并继续处理其他管?
- ios - Swift:转义闭包捕获非转义参数“onCompletion”
- semantic-ui - 选项卡中的关闭图标
- c# - 为什么 ToolStrip 控件 (Segoe UI 16) 和所有其他控件 (Microsoft Sans Serif 13) 有不同的字体?
- typescript - 在 tupescript mixin 错误中访问 vue 组件 getter (TS2339)
- javascript - 获得最大高度,用户在网页内移动
- swift - 如何在委托协议模式中使用相同的实例?
- javascript - Vue:计算属性未传递给子组件(控制台记录“空字符串”)
- c++ - 如何在对对象使用右值时适当地调用复制构造函数?
- apache-kafka - 从 kafka 读取时删除重复消息