亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Zone.js 檢測到 ZoneAwarePromise

Zone.js 檢測到 ZoneAwarePromise

慕絲7291255 2021-10-21 14:49:15
我正在嘗試在我的應用程序中使用 Typeform 庫,但是我遇到了很多問題。加載 js 腳本后,Angular 區域錯誤,我收到此消息:錯誤:Zone.js 檢測到 ZoneAwarePromise(window|global).Promise已被覆蓋。最可能的原因是在 Zone.js 之后加載了 Promise polyfill(加載 zone.js 時不需要 Polyfilling Promise api。如果必須加載,請在加載 zone.js 之前加載。)我的 app.component.ts 的代碼是:import { Component, Inject, AfterViewInit} from '@angular/core';import { DOCUMENT } from '@angular/common';import * as typeformEmbed from '@typeform/embed';@Component({  selector: 'my-app',  template: `<div #my_typeform></div>`,})export class AppComponent implements AfterViewInit {  constructor(    @Inject(DOCUMENT) private document: Document  ){}  ngAfterViewInit() {    const element = this.document.getElementById.call(document, 'my_typeform');    typeformEmbed.makeWidget(element, 'https://jonathan.typeform.com/to/zvlr4L', { onSubmit: () => console.log('Close') });  }}我嘗試手動運行 ngZone 以確保它在 Angular zone 內運行,但沒有奏效。在這種情況下, app.component.ts 就像import { Component, Inject, AfterViewInit, NgZone} from '@angular/core';import { DOCUMENT } from '@angular/common';import * as typeformEmbed from '@typeform/embed';@Component({  selector: 'my-app',  template: `<div #my_typeform></div>`,})export class AppComponent implements AfterViewInit {  constructor(    @Inject(DOCUMENT) private document: any,    @Inject(NgZone) private ngZone: NgZone  ){}  ngAfterViewInit() {    this.ngZone.run(() => {      const element = this.document.getElementById.call(document, 'my_typeform');      typeformEmbed.makeWidget(element, 'https://jonathan.typeform.com/to/zvlr4L', { onSubmit: () => console.log('Close') });    });  }}我還嘗試在我的 polyfill.ts 文件中導入 'zone.js/dist/zone-patch-rxjs',但它也不起作用。您可以在https://stackblitz.com/edit/angular-issue-repro2-daytbo 中看到一個具有最少代碼的項目來重現它任何線索或幫助都非常受歡迎!
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 434 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號