小编sel*_*ohn的帖子

Zone.js检测到ZoneAwarePromise`(window | global).Promise`已被自定义元素覆盖

我使用角度自定义元素功能(element.js)创建了一个小应用程序,将那个element.js文件导入到index.html中的另一个angular(parent)应用程序中,在开发服务器(ng serve)元素功能正常,但是在生产模式下(ng build --prod)在element.js文件中得到此错误。

@ angular / core“:”〜8.1.3“,@ angular / elements”:“ ^ 8.1.3”

element (angular custom element code)
polyfills.ts

import 'zone.js/dist/zone';  // Included with Angular CLI.
import "@webcomponents/custom-elements/src/native-shim";
import "@webcomponents/custom-elements/custom-elements.min";

app.module.ts
export class AppModule {
  constructor(private injector: Injector) { }

  ngDoBootstrap() {

    const el = createCustomElement(NotificationElementComponent, {
      injector: this.injector
    });
    // using built in the browser to create your own custome element name
    customElements.define('test-card', el);
  }
}


Run Code Online (Sandbox Code Playgroud)
angular (parent app)
index.html
<!doctype html>
<html lang="en">
<body>
    <app-root></app-root>
    <script src="./assets/elements.js"></script>
</body> …
Run Code Online (Sandbox Code Playgroud)

web-component zone.js angular angular-elements angular8

5
推荐指数
1
解决办法
896
查看次数