代码之家  ›  专栏  ›  技术社区  ›  Samuel Colvin

Google Recaptcha v3左下角

  •  1
  • Samuel Colvin  · 技术社区  · 6 年前

    在阅读代码 https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js 有很多人提到 bottomleft (与 bottomright 我想,通常放置图标的位置)。

    但如何启用此设置并将图标移到左下角?

    1 回复  |  直到 6 年前
        1
  •  4
  •   Samuel Colvin    6 年前

    就这样解决了。您需要:

    window._grecaptcha_callback = () => {
      window.grecaptcha.render({
        sitekey: grecaptcha_key,
        badge: 'bottomleft',
      })
      window.grecaptcha.ready(() => {
        // grecaptcha is ready
      })
    }
    

    然后将脚本加载为 https://www.google.com/recaptcha/api.js?onload=_grecaptcha_callback .

    这样,调用execute的方式必须稍微更改为

    window.grecaptcha.execute(0, {action})
    

    如。 0 而不是将站点密钥作为第一个参数。

    查看代码时,还有许多其他未记录的设置:

    sitekey, type, theme, size, tabindex, stoken, bind, preload, badge, s, pool, 'content-binding', action
    

    但除了T sitekey badge 我不知道他们在做什么。但它们可能与 settings for v2 .

    推荐文章