我在我的 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 包的内部问题。
如果可以 - 忽略它。将此错误添加到您的端到端测试或前端监控软件的白名单中。
否则,您可以手动覆盖 RecaptchaComponent
的 ngOnDestroy
方法(或创建组件分支)。请注意,此 是一个临时且非常糟糕的修复程序,可能会使您在升级组件版本时处于非常不幸的境地! 尽管如此,这里是大致的代码:
// 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/