0

我正在尝试使用 Angular cli 在 Angular 7 应用程序中使用 FullCalendar v4,并且在构建过程中遇到 Typescript 错误,并且浏览器中出现控制台错误,指出未定义“日历”。不确定我做错了什么,因为我似乎在遵循所有方向。我已将此添加到一个最小的角度应用程序中,并在 css 下方添加了受影响的文件,但这不应该影响它。

注意 - 我在这里的一个 stackblitz 示例中克隆了它,一切似乎都工作得很好,但是当在 angular cli 中多次本地重新创建它时,我仍然得到相同的结果。

https://stackblitz.com/edit/angular-lec711

包.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>

在此处输入图像描述

在此处输入图像描述

4

1 回答 1

1

我刚刚将我的 package.json 中的 TypeScript 更新为"typescript": "~3.2.2",现在我可以构建并且没有收到错误。

于 2019-03-08T00:38:00.793 回答