简体   繁体   English

重新验证 v3 集成

[英]Re-captcha v3 integration

I'm trying to integrate reCaptcha V3我正在尝试集成reCaptcha V3

what I tried is:我试过的是:

<script defer="defer"
        type="text/javascript"
        src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&amp;render=6Lda2XgUAAAAAKxRqwe9zBL09zv2ja1DYV-r">
</script>
<script type="text/javascript">
    var onloadCallback = function(){
        grecaptcha.execute('6Lda2XgUAAAAAKxRaqwev2ja1DYV-r', {action: '/foo/bar/'}).then(function(token) {
            alert(token)
        });
    };
</script>

But on loading page I get (index):1 Uncaught (in promise) null Does somebody know the reason and how could i fix it?但是在加载页面上我得到(index):1 Uncaught (in promise) null有人知道原因吗,我该如何解决?

EDIT: I catched this error:编辑:我发现了这个错误:

Uncaught TypeError: grecaptcha.execute(...).then(...).catch is not a function
    at onloadCallback ((index):18)
    at gf (recaptcha__pl.js:512)
    at Gj (recaptcha__pl.js:508)
    at recaptcha__pl.js:520
    at recaptcha__pl.js:539
onloadCallback @ (index):18
gf @ recaptcha__pl.js:512
Gj @ recaptcha__pl.js:508
(anonymous) @ recaptcha__pl.js:520
(anonymous) @ recaptcha__pl.js:539
(index):1 Uncaught (in promise) null

grecaptcha.execute is created in the first script grecaptcha.execute 在第一个脚本中创建

the defer attribute will wait for page to load before executing it. defer 属性将在执行之前等待页面加载。

So removing the defer should make it.所以删除 defer 应该可以。

Note: defer is not appearing in the official integration documentation注意:defer 没有出现在官方集成文档中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM