我使用firebase生成otp,我得到一个关于appVerificationDisabledForTesting未定义的错误。
recaptcha_verifier.ts:114 Uncaught TypeError: Cannot read properties of undefined (reading 'appVerificationDisabledForTesting')
at new RecaptchaVerifier (recaptcha_verifier.ts:114:1)
at generateRecaptcha (Home.js:123:1)
at handleSend (Home.js:139:1)
字符串
这是我使用的代码
const handleSend = (event) => {
event.preventDefault();
generateRecaptcha();
let appVerifier = window.recaptchaVerifier;
signInWithPhoneNumber(auth, phoneNumber, appVerifier)
.then((confirmationResult) => {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
window.confirmationResult = confirmationResult;
})
.catch((error) => {
// Error; SMS not sent
console.log(error);
});
};
型
错误来自generateRecaptcha();
const generateRecaptcha = () => {
window.recaptchaVerifier = new RecaptchaVerifier(
"recaptcha",
{
size: "invisible",
callback: (response) => {
// reCAPTCHA solved, allow signInWithPhoneNumber.
// ...
},
},
auth
);
};
型
1条答案
按热度按时间5fjcxozz1#
“firebase”:“^9.4.1”
将firebase版本更改为9. 4. 1,它将工作,我也陷入了这个错误,并一直在寻找解决方案,这是我现在得到的唯一解决方案