1

ckeditor 工作得很好,只是 ngOnDestroy 处理程序崩溃了。

"dependencies": {
    "@angular/common": "8.0.0",
    "@angular/compiler": "8.0.0",
    "@angular/core": "8.0.0",
    "@angular/forms": "8.0.0",
    "@angular/platform-browser": "8.0.0",
    "@angular/platform-browser-dynamic": "8.0.0",
    "@angular/router": "8.0.0",
    "@ckeditor/ckeditor5-angular": "1.1.0",
    "@ckeditor/ckeditor5-basic-styles": "11.1.4",
    "@ckeditor/ckeditor5-build-classic": "12.4.0",
     ....
    "zone.js": "0.10.0"
  },

我正在使用带有插件“TerserPlugin”的 webpack 来最小化。问题似乎来自

terserOptions: {
                    ecma: 6,
                    ie8: false,
                    toplevel: true,
                    module: true,
                    compress: {
                        dead_code: true,
                        warnings: false,
                        properties: true,
                        drop_debugger: true,
                        conditionals: true,
                        booleans: true,
                        loops: true,
                        unused: true,
                        toplevel: true,
                        if_return: true,
                        inline: true,
                        join_vars: true,
                        ecma: 6,
                        module: true,
                        toplevel: true
                    },
                    output: {
                        comments: false,
                        beautify: false,
                        indent_level: 2,
                        ecma: 6
                    },
                    mangle: {
                        module: true,
                        toplevel: true
                    }
                }

为了尝试,我以这种方式更改了 polyfills.ts 文件中的 zone.js:

import 'core-js/proposals/reflect-metadata';
import 'zone.js/dist/zone.js';
(window as any).__Zone_disable_toString = true;
require('../manifest.webapp');

但不为我工作。

这是错误:

ERROR TypeError: Cannot read property 'data-ck-expando' of undefined
    at Si (4.83409f22a2c74d96c1fe.chunk.js:1)
    at Oa._getProxyEmitter (4.83409f22a2c74d96c1fe.chunk.js:1)
    at Oa.stopListening (4.83409f22a2c74d96c1fe.chunk.js:1)
    at Oa.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
    at Oa.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
    at ea.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
    at Ip.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
    at e.ngOnDestroy (main.83409f22a2c74d96c1fe.bundle.js:1)
    at ug (main.83409f22a2c74d96c1fe.bundle.js:1)
    at lg (main.83409f22a2c74d96c1fe.bundle.js:1)

4

4 回答 4

2

polyfills.ts中更改这一行:

导入'zone.js/dist/zone';// 包含在 Angular CLI 中。

导入'zone.js/dist/zone.js';// 包含在 Angular CLI 中。

于 2019-11-13T10:05:52.087 回答
1

您需要关闭模块属性。Module (default false) -- 压缩 ES6 模块时传递 true。隐含严格模式和顶级选项。文档:https ://github.com/terser/terser#compress-options

terserOptions: {
  compress: {
    module: false // here
  }
}
于 2020-12-30T09:52:38.000 回答
0

安德鲁的回答是什么对我有用。我正在使用具有新功能的 ckfinder 在编辑器中插入原始 html 代码。我尝试将 zone.js 版本更新为 0.10.0,也尝试修改文件 polyfills.ts,但它不起作用。

只需在以下文件中将模块属性设置为 false:webpack.js

结构如下:

terserOptions: {
  compress: {
    module: false 
  }
}

Ps.:我还不能评论,因为我没有足够的积分:(

于 2021-05-07T15:37:48.183 回答
0

删除 polyfill.ts 中的所有代码并添加以下代码

 import 'zone.js/dist/zone.js';  // Included with Angular CLI.
 (window as any).__Zone_disable_toString = true;

这应该可以解决您的问题

于 2019-11-18T19:56:04.103 回答