首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FullCalendar排定程序-类型“string”不可分配给类型“EmitterInterface[]”

FullCalendar排定程序-类型“string”不可分配给类型“EmitterInterface[]”
EN

Stack Overflow用户
提问于 2018-03-02 21:19:03
回答 1查看 680关注 0票数 2

我正在尝试在Angular 2中实现FullCalendar Scheduler,我遵循了以下指定的步骤-

安装了所需的依赖项,如下所示-

代码语言:javascript
复制
"dependencies": {
   "fullcalendar": "^3.8.0",
    "fullcalendar-scheduler": "^1.9.1",
    "jquery": "^3.2.1",
    "moment": "^2.20.1"
  },
  "devDependencies": {
    "@types/jquery": "^2.0.47"
  }

更新了angular-cli.json,如下-

代码语言:javascript
复制
"styles": [
            "styles.css",
            "../node_modules/bootstrap/dist/css/bootstrap.min.css",
            "../node_modules/fullcalendar/dist/fullcalendar.min.css",
            "../node_modules/fullcalendar-scheduler/dist/scheduler.min.css",
            "../node_modules/primeng/resources/primeng.min.css",
            "../node_modules/primeng/resources/themes/omega/theme.css",
            "../node_modules/font-awesome/css/font-awesome.min.css"
        ],
        "scripts": ["../node_modules/jquery/dist/jquery.js",
            "../node_modules/moment/min/moment.min.js",
            "../node_modules/fullcalendar/dist/fullcalendar.js",
             "../node_modules/fullcalendar-scheduler/dist/scheduler.min.js"
        ],

我已经在main.tsmodule.ts中导入了依赖项-

main.ts -

代码语言:javascript
复制
import * as jQuery from "jquery";
(window as any).$ = (window as any).jQuery = jQuery;

app.component.html -

代码语言:javascript
复制
<div id='calendar'></div>

app.component.ts

代码语言:javascript
复制
import { Component } from '@angular/core';
import 'fullcalendar';
import 'fullcalendar-scheduler';
declare let $: any;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  ngOnInit() {
    $('#calendar').fullCalendar({});
  }
}

我已经解决了jQuery错误中指定的@type/jquery问题,但是我无法编译它给出的下面提到的错误的代码。

代码语言:javascript
复制
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (347,6): Type 'string' is not assignable to type 'EmitterInterface[]'.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (124,27): ']' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (125,28): ']' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (125,33): ';' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (126,28): ']' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (126,33): ';' expected.

请找到full error here。我已经看了下面的线程和资源,这些似乎并没有解决这个问题--

https://github.com/fullcalendar/fullcalendar/issues/3991 fullcalendar & Angular 5

关于这一点,我请求您的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-05 21:49:08

这对你来说应该是可行的。此外,您还可以在这里查看git存储库https://gitlab.com/haque.mdmanzurul/ng-fullcalendar

app.component.ts

代码语言:javascript
复制
import * as jQuery from 'jquery';
(window as any).jQuery = (window as any).$ = jQuery; // This is needed to resolve issue.
import { Component, OnInit } from '@angular/core';
import 'fullcalendar';

 @Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['./app.component.css']
 })
 export class AppComponent implements OnInit {
 title = 'My Calendar';

 ngOnInit() {
   $('#calendar').fullCalendar({});
 }
}

angular-cli.json:

代码语言:javascript
复制
"styles": [
    "styles.css",
    "../node_modules/fullcalendar/dist/fullcalendar.min.css"
  ],
  "scripts": [
    "../node_modules/fullcalendar/dist/fullcalendar.js"
  ],

package.json

代码语言:javascript
复制
{
  "name": "mycalendar",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},
"private": true,
"dependencies": {
 "@angular/animations": "^4.2.4",
 "@angular/common": "^4.2.4",
 "@angular/compiler": "^4.2.4",
 "@angular/core": "^4.2.4",
 "@angular/forms": "^4.2.4",
 "@angular/http": "^4.2.4",
 "@angular/platform-browser": "^4.2.4",
 "@angular/platform-browser-dynamic": "^4.2.4",
 "@angular/router": "^4.2.4",
 "core-js": "^2.4.1",
 "rxjs": "^5.4.2",
 "zone.js": "^0.8.14",
 "fullcalendar": "^3.4.0",
 "jquery": "^3.2.1",
 "moment": "^2.19.1"
 },
"devDependencies": {
 "@angular/cli": "1.4.9",
 "@angular/compiler-cli": "^4.2.4",
 "@angular/language-service": "^4.2.4",
 "@types/jasmine": "~2.5.53",
 "@types/jasminewd2": "~2.0.2",
 "@types/jquery": "^3.2.7",
 "@types/node": "~6.0.60",
 "codelyzer": "~3.2.0",
 "jasmine-core": "~2.6.2",
 "jasmine-spec-reporter": "~4.1.0",
 "karma": "~1.7.0",
 "karma-chrome-launcher": "~2.1.1",
 "karma-cli": "~1.0.1",
 "karma-coverage-istanbul-reporter": "^1.2.1",
 "karma-jasmine": "~1.1.0",
 "karma-jasmine-html-reporter": "^0.2.2",
 "protractor": "~5.1.2",
 "ts-node": "~3.2.0",
 "tslint": "~5.7.0",
 "typescript": "~2.3.3"
 }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49069936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档