[英]New ReCaptcha (invisible) not working
I am trying to implement the new invisible reCaptcha, but it is not working. 我正在尝试实现新的不可见reCaptcha,但是它不起作用。
First, event tough I have created a new key with the "invisible" option, changed the key in my application, when I look in my console I can see this request: 首先,如果遇到困难,我用“ invisible”选项创建了一个新密钥,更改了应用程序中的密钥,当我在控制台中查看时,可以看到以下请求:
https://www.google.com/recaptcha/ api2 /anchor?k=.....
https://www.google.com/recaptcha/ api2 / anchor?k = .....
I think this is not the correct api, right? 我认为这不是正确的api,对吗?
My code for the importing part is like this: 我的导入部分代码如下:
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
Which is right according to the doc... 根据文档正确...
Second, I chose to put the captcha in a div (which is ok according to the doc): 其次,我选择将验证码放在div中(根据文档可以):
<div id="captchaSignup" class="g-recaptcha" data-size="invisible" data-badge="inline"></div>
I am also using the render function to declare the callback and the site-key: 我还使用render函数声明回调和site-key:
grecaptcha.render(document.getElementById('captchaSignup'), { 'sitekey' : '...', 'callback' : function(response) {$rs.validCaptcha=response;$s.$apply()} });
This works as a captcha solution, but not as the invisible one since it is still showing the box. 这可以用作验证码解决方案,但由于它仍在显示方框,因此不能用作不可见的解决方案。 I know that I also have to use the execute function, but since I am still seeing the box, I think I am not in that phase yet.. Can anybody help me?
我知道我也必须使用execute函数,但是由于我仍然看到方框,所以我认为我还没有进入这个阶段。有人可以帮助我吗?
In case of "invisible" recaptcha, grecaptcha.render()
api takes optional third boolean parameter called inherit
and defaults to false
. 如果是“不可见”的
grecaptcha.render()
,则grecaptcha.render()
api将使用可选的第三个布尔参数,称为inherit
,默认为false
。 If its value is specified as true
, only then recaptcha uses existing data-* attributes on .g-recaptcha
element for parameters not specified in options to render()
, otherwise it treats as if the parameter is missing. 如果将其值指定为
true
,则只有Recaptcha才会对.g-recaptcha
元素上的现存data- *属性使用render()
选项中未指定的参数,否则它将视为缺少该参数。
Since you are not passing this parameter with true
value, it never reads data-size="invisible"
value that you have on your HTML element and thereby goes on to render it as visible recaptcha. 由于您没有传递带有
true
值的此参数,因此它永远不会读取HTML元素上具有的data-size="invisible"
值,从而继续将其呈现为可见的Recaptcha。
Try this: 尝试这个:
grecaptcha.render(document.getElementById('captchaSignup'), {
'sitekey' : '...',
'callback' : function(response) { ... }
}, true); // <-- this is the change. Pass "true" here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.