firebase 文档参考了 grecaptcha 但从不导入或定义它

ast*_*mme 7 javascript recaptcha firebase firebase-authentication

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);
}
Run Code Online (Sandbox Code Playgroud)

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

ast*_*mme 7

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

/* global grecaptcha */
Run Code Online (Sandbox Code Playgroud)

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