我正在尝试使用CKEditor5 npm包在我的站点上设置@ckeditor/ckeditor5-build-classic。我安装了12.0.0版本,这是今天的最新版本。
我正在使用下面的设置方法- https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/advanced-setup.html#scenario-1-integrating-existing-builds,这看起来应该非常简单。
我使用的是TypeScript,模块中有以下代码:
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
ClassicEditor
.create(document.querySelector('.html-editor'))
.then(editor => {
console.log(editor);
})
.catch(error => {
console.error(error);
});...which被转换为以下JavaScript:
var ckeditor5_build_classic_1 = require("@ckeditor/ckeditor5-build-classic");
ckeditor5_build_classic_1["default"]
.create(document.querySelector('.html-editor'))
.then(function (editor) {
console.log(editor);
})["catch"](function (error) {
console.error(error);
});不幸的是,在加载页面时出现了以下错误:
addadventure.ts:11 Uncaught TypeError: Cannot read property 'create' of undefined
at Object.<anonymous> (addadventure.ts:11)
at Object../wwwroot/js/pages/adventures/addadventure.ts (addadventure.ts:266)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Object.1 (addadventure.ts:266)
at __webpack_require__ (bootstrap:781)
at checkDeferredModules (bootstrap:45)
at bootstrap:857
at bootstrap:857它知道ckeditor5_build_classic_1是一个类,但ckeditor5_build_classic_1["default"]是未定义的。
编辑:
奇怪的是,如果我在它失败的行上放置了一个断点,然后在控制台中运行以下命令,它就能工作.
ckeditor5_build_classic_1.create(document.querySelector('.html-editor'))那么问题就出在转移了吗?
发布于 2019-04-02 16:40:25
你试过用这个import吗?
import * as InlineEditor from '@ckeditor/ckeditor5-build-inline';发布于 2019-03-19 16:00:55
您是否尝试设置/取消设置esModuleInterop和allowSyntheticDefaultImports编译器选项?
https://stackoverflow.com/questions/55048427
复制相似问题