应用程序死于卸载状态:无法读取未定义的 属性 'injector'

Application died in status UNMOUNTING: Cannot read property 'injector' of undefined

我正在使用 Single-Spa-Angular 库构建微前端。我使用 "ng add single-spa-angular" 创建了三个不同的子应用程序,其中两个应用程序工作正常,但一个应用程序显示以下错误:

Uncaught app2: Application 'app2' died in status UNMOUNTING: Cannot read property 'injector' of undefined
    at http://<HOSTNAME>:4202/main.js:204363:53

Uncaught app2: Application 'app2' died in status SKIP_BECAUSE_BROKEN: In this configuration Angular requires Zone.js
    at new NgZone (http://<HOST>:4202/main.js:68725:19)
    at getNgZone (http://<HOST>:4202/main.js:69414:13)
    at PlatformRef../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModuleFactory (http://<HOST>:4202/main.js:69312:22)
    at http://<HOST>:4202/main.js:69356:59

谁能帮帮我。

谢谢 Shashi Bhushan Verma

我遇到了同样的问题。在您的 main.single-spa.ts 文件中添加以下行:

导入'zone.js/dist/zone';

这似乎对我有用。

您也可以在 root-config.js 文件中添加 zone.js 作为脚本,如下所示。

<script src="https://cdn.jsdelivr.net/npm/zone.js@0.10.3/dist/zone.min.js"></script>

正如 single-spa 官方文档所述

The preferred way to ensure only one instance of ZoneJS is loaded on your page is with a script tag in your root-config's HTML file. You should load ZoneJS upfront a single time, before loading SystemJS or any of your microfrontends.

供大家参考docuementation