【发布时间】:2020-08-21 20:12:09
【问题描述】:
下面是显示的错误
Uncaught TypeError: Cannot read property 'auth' of undefined
at HTMLButtonElement.eval (Login.vue?7463:65)
at HTMLButtonElement.dispatch (jquery.js?1157:5429)
at HTMLButtonElement.elemData.handle (jquery.js?1157:5233)
下面是我的代码
mounted() {
window.$("#submit").click(function() {
var input = window
.$("#inputPhone")
.val()
.trim();
if (input.length > 13 || input.length < 10 || isNaN(input)) {
alert("Please enter a valid phone no");
} else {
window.$("#phone").hide();
window.$("#code").show();
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
"submit",
{
size: "invisible"
}
);
// window.recaptchaVerifier = new firebase.auth().RecaptchaVerifier('submit', {
// 'size': 'invisible',
// 'callback': function(response) {
// // reCAPTCHA solved, allow signInWithPhoneNumber.
// console.log(response);
// }
// });
firebase
.auth()
.signInWithPhoneNumber(input, window.recaptchaVerifier)
.then(function(confirmationResult) {
window.confirmationResult = confirmationResult;
console.log(confirmationResult);
});
window.$("#login").click(function() {
var inp = window
.$("")
.val()
.trim();
if (inp.length === 0) {
alert("Please enter code");
} else {
var myFunction = function() {
window.confirmationResult
.confirm(inp)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log(error);
});
};
myFunction();
}
});
}
});
}
请查看我的代码并帮助我。
下面是我导入的配置代码
下面是我导入的配置代码
下面是我导入的配置代码
下面是我导入的配置代码
下面是我导入的配置代码
import { firebase } from "../firebase";
根据 chrome 开发者工具,错误出现在下面的代码行中
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
"submit",
{
size: "invisible"
}
);
【问题讨论】:
-
firebase 未定义,是否添加了配置对象?
-
是的,我添加了配置
-
尝试调试。在 Chrome 中,右键单击 -> Inspect -> Sources 然后添加断点并调试
-
我无法调试,错误仍然出现
标签: javascript firebase vue.js firebase-authentication