我正在尝试在我的应用程序中使用 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') });
}
} …Run Code Online (Sandbox Code Playgroud)