【问题标题】:Using CKEditor.d.ts typescript definition file in angular 2 [duplicate]在角度2中使用CKEditor.d.ts打字稿定义文件[重复]
【发布时间】:2016-04-13 08:16:13
【问题描述】:

我有一个 Angular 2 的项目,我想使用来自definitelyTyped Repo 的 CKEditor 打字稿定义

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/ckeditor/ckeditor.d.ts

问题是我收到错误Evaluating http://localhost:3000/typings/ckeditor/ckeditor.d.ts 这是我包含 ckeditor 文件的代码。

import {CoursesService} from "../../../services/courses"
/// <reference path="../../../../typings/ckeditor/ckeditor.d.ts" />

import {CKEDITOR} from "../../../../typings/ckeditor/ckeditor.d.ts"
export class CreateCourseComponent implements OnInit {
    ngOnInit(){
        CKEDITOR.replace('text_area');
    }
}

【问题讨论】:

  • 不,这不是那个问题的重复。这个问题是关于如何使用 CKEDITOR。这一篇是关于如何为CKEDITOR 使用DefinitelyTyped 类型定义。它们是互补的。
  • 这是这个问题的答案:(1)运行npm install -D @types/ckeditor(2)将其添加到您将访问CKEDITOR全局的打字稿文件的最顶部(必须是第一行,或在其他三斜杠指令之后):///&lt;reference types="ckeditor" /&gt;

标签: angular angular2-directives


【解决方案1】:

定义文件不是模块,只是它的编译时间,所以去掉这一行:

import {CKEDITOR} from "../../../../typings/ckeditor/ckeditor.d.ts" 

并使用脚本标签导入CKEditor。

【讨论】:

  • 删除这一行并不能解决这个问题,它会产生错误CKEditor is not defined
猜你喜欢
  • 1970-01-01
  • 2018-09-01
  • 2016-12-05
  • 2016-12-03
  • 2015-09-05
  • 2016-01-20
  • 2013-08-16
  • 2019-03-28
  • 1970-01-01
相关资源
最近更新 更多