Javascript 使用EmailandPassword()登录的auth.signin中出现问题
我的代码中使用auth的登录功能不起作用。以下是代码:Javascript 使用EmailandPassword()登录的auth.signin中出现问题,javascript,html,firebase,firebase-authentication,Javascript,Html,Firebase,Firebase Authentication,我的代码中使用auth的登录功能不起作用。以下是代码: function login(){ var email = document.getElementById("emailid").value; var password = document.getElementById("pass_word").value; firebase.auth().signInWithEmailAndPassword(email, password) .
function login(){
var email = document.getElementById("emailid").value;
var password = document.getElementById("pass_word").value;
firebase.auth().signInWithEmailAndPassword(email, password)
.catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(error);
});
}
我们在登录中写的任何东西,但在登录之前和之后
firebase.auth().signInWithEmailAndPassword()
方法正在工作。如果我试图在其中写入任何不起作用的内容,甚至连警告消息都没有
提前感谢。您是否启用了firebase控制台中的电子邮件登录。 如果你不这样做,它就不会起作用
signInWithEmailAndPassword(email, password)
是一种在执行时返回承诺的方法,因此需要调用
signInWithEmailAndPassword(email, password).then(res => {
//YOUR_CODE_HERE
})
对成功执行作出反应
此处提供了实现登录过程的完整教程:进行此操作时是否拥有帐户如果要创建帐户,则应使用
不
使用email和password(email,password)
登录,这只对现有帐户有效。我也尝试过这种方法。但仍然没有用。是的,我也这么做了。我已经有一个帐户了。我只是尝试登录