javascript - 未处理的 promise 拒绝 : Timeout ; Zone: Recaptcha

标签 javascript angular

我在我的 Angular 页面上添加了 recaptcha。在我解析 recaptcha 后,大约 10 秒后似乎出现错误。未处理的 promise 拒绝:超时;区域: ;任务:Promise.then;值:超时未定义。

import { Component, OnInit, OnDestroy, ElementRef, ViewChild } from '@angular/core';
import { ApiService } from '../../services/api.service';

@Component({
  selector: 'app-tdec-captcha',
  templateUrl: './tdec-captcha.component.html',
  styleUrls: ['./tdec-captcha.component.scss']
})
export class TdecCaptchaComponent implements OnInit, OnDestroy {
 
  constructor(private apiService: ApiService) { }

  ngOnInit() {
  }
  ngOnDestroy(){

  }

  relolved = function (event: any) {
    //this.re_Captcha = event
    if (event !== null) {
      this.apiService.re_Captcha = true;    
    }  
  }
}
<div class="overlay">
  <div #captcha>
    <re-captcha class="captcha" (resolved)="relolved($event)" siteKey="6wekif9g88gwZAAasYncf6GHj5F6dvpkQ_90000Bp
"></re-captcha> 
  </div>enter code here
</div>

最佳答案

这是由于 ng-recaptcha 包的内部问题。

如果可以 - 忽略它。将此错误添加到您的端到端测试或前端监控软件的白名单中。

否则,您可以手动覆盖 RecaptchaComponentngOnDestroy 方法(或创建组件分支)。请注意,此 是一个临时且非常糟糕的修复程序,可能会使您在升级组件版本时处于非常不幸的境地! 尽管如此,这里是大致的代码:

// somewhere in your "main.ts"
import { RecaptchaComponent } from 'ng-recaptcha';
RecaptchaComponent.prototype.ngOnDestroy = function() {
  if (this.subscription) {
    this.subscription.unsubscribe();
  }
}

(注:摘自ng-recaptcha tag causes error “zone.js: Unhandled Promise rejection” when route changes)

关于javascript - 未处理的 promise 拒绝 : Timeout ; Zone: Recaptcha,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63893543/

相关文章:

javascript - 在这种情况下我需要使用 setState(function) 重载吗?

javascript - Jasmine 运行测试 3 次

javascript - 每个元素的 jQuery 动画

javascript - 未捕获的语法错误 : await is only valid in async function (its in an async function though. ...)

javascript - angular2单元测试中按标签名统计子组件数量

javascript - 从数组数组中对日期 mm/dd/yyyy 字段进行排序

angularjs - Angular 相当于 AngularJS $watch 是什么?

javascript - (未知网址)Angular 4 的 Http 失败响应

javascript - 表排序在 IE 7 中不起作用

javascript - 如何选择下拉列表项