@types/ckeditor 的问题
Issues with @types/ckeditor
我在使用来自以下来源的@types/ckeditor 时遇到了一些问题。
https://www.npmjs.com/package/@types/ckeditor
我已经安装好了包,然后将类型导入相关文件,在VS代码中都是绿色的。
import "CKEDITOR";
import { Injectable } from '@angular/core';
export interface IEditor {
editor: CKEDITOR.editor
addEventHandler(eventName: string, onEvent: Function): void;
addContextMenuItem(menulabel: string, onEvent: Function): void;
getTrackingPlugin(): any;
}
@Injectable({
providedIn: 'root'
})
export class Editor implements IEditor {
public editor: CKEDITOR.editor
constructor(rootElement: HTMLElement, config: CKEDITOR.config) {
this.editor = CKEDITOR.inline(rootElement, config);
}
}
太好了,但是当我进行构建时,出现以下错误。
ERROR in ./src/app/modules/single-editor/services/editor.service.ts
Module not found: Error: Can't resolve 'CKEDITOR' in 'C:\Code\***\src\web\src\app\modules\single-editor\services'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! web@0.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\***\AppData\Roaming\npm-cache\_logs19-05-07T10_31_08_926Z-debug.log
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
这段代码在它自己的模块中,我使用的是最新版本的 Angular,我使用的是 ckeditor 4。
我相信我已经找到了答案。我需要包括以下内容。
/// <reference types="@types/ckeditor" />
我以前试过这个但没用,但我做错的关键是没有将它包含在文件的最开头,这很重要.
我在使用来自以下来源的@types/ckeditor 时遇到了一些问题。
https://www.npmjs.com/package/@types/ckeditor
我已经安装好了包,然后将类型导入相关文件,在VS代码中都是绿色的。
import "CKEDITOR";
import { Injectable } from '@angular/core';
export interface IEditor {
editor: CKEDITOR.editor
addEventHandler(eventName: string, onEvent: Function): void;
addContextMenuItem(menulabel: string, onEvent: Function): void;
getTrackingPlugin(): any;
}
@Injectable({
providedIn: 'root'
})
export class Editor implements IEditor {
public editor: CKEDITOR.editor
constructor(rootElement: HTMLElement, config: CKEDITOR.config) {
this.editor = CKEDITOR.inline(rootElement, config);
}
}
太好了,但是当我进行构建时,出现以下错误。
ERROR in ./src/app/modules/single-editor/services/editor.service.ts
Module not found: Error: Can't resolve 'CKEDITOR' in 'C:\Code\***\src\web\src\app\modules\single-editor\services'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! web@0.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\***\AppData\Roaming\npm-cache\_logs19-05-07T10_31_08_926Z-debug.log
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
这段代码在它自己的模块中,我使用的是最新版本的 Angular,我使用的是 ckeditor 4。
我相信我已经找到了答案。我需要包括以下内容。
/// <reference types="@types/ckeditor" />
我以前试过这个但没用,但我做错的关键是没有将它包含在文件的最开头,这很重要.