我正在使用 Angular 6 实现 Google reCAPTCHA v3。
<script src='https://www.google.com/recaptcha/api.js?render=KEY'></script>
在中添加脚本index.html
在我的 AppComponent 中,
constructor(
@Inject(DOCUMENT) private document: any
) {
this.grecaptcha = this.document.grecaptcha;
}
当我点击表单提交时,
this.grecaptcha.execute('KEY', { action: 'action_name' })
.then(function (token) {
// Verify the token on the server.
console.log(token);
});
但,
错误类型错误:无法读取未定义的属性“执行”