我正在尝试使用angular cli在Angular 7应用程序中使用FullCalendar v4,并且在构建期间出现Typescript错误以及浏览器中的控制台错误,指出未定义'Calendar'。不确定我在做什么,因为我似乎在遵循所有方向。我已将其添加到最小的角度应用程序中,并添加了在css栏下方生效的文件,但这不应生效。
注意-我在这里的stackblitz示例中将其克隆了,一切似乎都正常,但是当在角度cli中在本地重新创建几次时,我仍然得到相同的结果。
https://stackblitz.com/edit/angular-lec711
package.json
{
"name": "fullcalendar",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.0.0",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"@fullcalendar/core": "4.0.0-beta.4",
"@fullcalendar/resource-timegrid": "4.0.0-beta.4",
"core-js": "^2.5.4",
"n": "^2.1.12",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "~7.0.4",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
}
}
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { Calendar } from '@fullcalendar/core';
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewInit {
@ViewChild('fullCalendarInstance') private fullCalendarInstance: any;
ngAfterViewInit() {
this.initFullCalendar();
}
initFullCalendar() {
const calendar = new Calendar(this.fullCalendarInstance.nativeElement, {
plugins: [resourceTimeGridPlugin],
timeZone: 'UTC',
defaultView: 'resourceTimeGridDay',
groupByResource: true,
resources: [
{ id: 'a', title: 'Room A' },
{ id: 'b', title: 'Room B' }
],
events: 'https://fullcalendar.io/demo-events.json?with-resources=2'
});
calendar.render();
}
}
<div #fullCalendarInstance></div>
答案 0 :(得分:1)
我刚刚将我package.json中的TypeScript更新为"typescript": "~3.2.2"
,现在可以构建并且不会收到错误了。