Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
hCaptcha JavaScript API呈现:无效容器';空';_Javascript_Api_Recaptcha_Captcha - Fatal编程技术网

hCaptcha JavaScript API呈现:无效容器';空';

hCaptcha JavaScript API呈现:无效容器';空';,javascript,api,recaptcha,captcha,Javascript,Api,Recaptcha,Captcha,我在opera开发者控制台上遇到这个错误。 我替换了我的站点密钥,它返回了无效的容器null 这是我的源代码 <html> <head> <script src="https://hcaptcha.com/1/api.js?onload=yourFunction&render=explicit" async defer></script> <script type="t

我在opera开发者控制台上遇到这个错误。 我替换了我的站点密钥,它返回了无效的容器null

这是我的源代码

<html>
    <head>
        <script src="https://hcaptcha.com/1/api.js?onload=yourFunction&render=explicit" async defer></script>
      <script type="text/javascript">
        var yourFunction = function () {
          console.log('hCaptcha is ready.');
          var widgetID = hcaptcha.render('captcha-1', { sitekey: 'MY_SITE_KEY' });
        };
      </script>
    </head>
    <body>
        <div class="h-captcha" data-sitekey="MY_SITE_KEY" data-theme="dark"></div>
    </body>
</html>

var yourFunction=函数(){
log('hCaptcha已准备就绪');
var widgetID=hcaptcha.render('captcha-1',{sitekey:'MY_SITE_KEY'});
};

当隐式调用
render
时,默认的
集装箱ID
h-captcha
,如目标div的
类中所定义

当显式调用
hcaptcha.render()
时,第一个参数是
containerId


由于这种行为,您的问题可以通过将
render()
调用的第一个参数更改为
h-captcha
而不是
captcha-1
,或者将
class
值更改为
captcha-1

来解决。如果像我这样的人尝试将class和id更改为h-captcha,这将是有效的。谢谢你的帮助