【发布时间】:2019-05-14 16:16:17
【问题描述】:
我正在使用 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);
});
但是,
ERROR TypeError: Cannot read property 'execute' of undefined
【问题讨论】:
标签: angular google-api recaptcha captcha recaptcha-v3