【问题标题】:firebase docs reference grecaptcha but never import or define itfirebase docs 引用 grecaptcha 但从不导入或定义它
【发布时间】:2017-10-11 18:41:18
【问题描述】:

来自https://firebase.google.com/docs/auth/web/phone-auth

如果 signInWithPhoneNumber 导致错误,请重置 reCAPTCHA,以便 用户可以再试一次:

grecaptcha.reset(window.recaptchaWidgetId);

// Or, if you haven't stored the widget ID:
window.recaptchaVerifier.render().then(function(widgetId) {
  grecaptcha.reset(widgetId);
}

grecaptcha 从未定义。我必须从某个地方导入它吗?

【问题讨论】:

    标签: javascript firebase firebase-authentication recaptcha


    【解决方案1】:

    看起来它是由 firebase 自动导入的。但是,因为我是从 ES2015 编译代码,所以我需要添加

    /* global grecaptcha */
    

    到我的 js 文件的顶部,使其对我的代码可见。

    【讨论】:

      【解决方案2】:

      是的,你需要导入它。

      这并不明显,但文档确实在“Use the reCAPTCHA widget”部分下引用了该库。

      他们有一个指向this page 的链接。我猜你会使用the reCAPTCHA V2

      【讨论】:

        【解决方案3】:

        如果尚未包含 grecaptcha 库,Firebase Auth JS 库将动态提取它。否则,如果您已经包含它:https://www.google.com/recaptcha/api.js,那么它将只使用该库。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-12-02
          • 1970-01-01
          • 2015-07-01
          • 1970-01-01
          • 2021-02-10
          • 2022-12-19
          • 2020-10-20
          • 2018-08-27
          相关资源
          最近更新 更多