首页 文章

如何在Angular应用程序中销毁ckeditor? [重复]

提问于
浏览
2

这个问题在这里已有答案:

我在Angular应用程序中使用ckeditor4 . 当我离开页面时,控制台会发出如下警告:

[CKEDITOR]错误代码:editor-destroy-iframe . ckeditor.js:21 [CKEDITOR]有关此错误的更多信息,请访问http://docs.ckeditor.com/#!/guide/dev_errors-section-editor-destroy-iframe

我该如何安全地卸载ckeditor组件?

2 回答

  • 5

    这就是我解决问题的方法:

    • 在你的html中添加插件'divarea',如下所示:

    <ckeditor [config]={extraPlugins: 'divarea'}></ckeditor>

    此时控制台仍会出现404错误:

    无法加载资源:服务器响应状态为404(未找到)

    • 最后,您需要将index.html中的包地址从“full”更改为“full-all” .

    <script src="https://cdn.ckeditor.com/4.5.11/full-all/ckeditor.js"></script>

    reference

  • 1

    错误中引用的页面中的详细信息说:

    编辑器无法正确销毁,因为它在编辑器被销毁之前已被卸载 . 确保在从DOM中分离编辑器之前销毁编辑器 .

    您应该在Angular Component的onDestroy事件中进行清理,这样在Angular删除周围的HTML元素之前它将被销毁 . 以下是onDestroy上的文档:

    https://angular.io/guide/lifecycle-hooks#ondestroy

相关问题