将Typeform嵌入角度应用程序不起作用?

我正在根据SDK在Angular组件中嵌入Typeform。

组件模板具有div:

<div
    #embedTypeform
    style="width: 100%; height: 500px;"
></div>

我在AfterViewInit中使用SDK:

import { Component,ElementRef,ViewChild,AfterViewInit } from '@angular/core';
import * as typeformEmbed from '@typeform/embed';

@Component({
  selector: 'app-answer-form',templateUrl: './answer-form.component.html',styleUrls: ['./answer-form.component.css']
})
export class AnswerFormComponent implements AfterViewInit {
  @ViewChild('embedTypeform',{ static: false }) embedElement: ElementRef;

  ngAfterViewInit() {
    if (this.embedElement) {
      console.log(this.embedElement);
      typeformEmbed.makeWidget(
        this.embedElement,'https://xxx.typeform.com/to/xxx',{
          hideHeaders: true,hideFooter: true,opacity: 75,buttonText: 'Take the survey!',onSubmit: () => {
            console.log('Typeform successfully submitted');
          }
        }
      );
    }
  }

}

实际上我得到了

TypeError: Cannot read property 'length' of undefined

有什么想法吗?

wdiaoniena 回答:将Typeform嵌入角度应用程序不起作用?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2684101.html

大家都在问