Firebase:该电子邮件地址已被其他帐户使用。 (auth/email-already-in-use)

Firebase: The email address is already in use by another account. (auth/email-already-in-use)

Firebase: The email address is already in use by another account. (auth/email-already-in-use).

这个错误来自 firebase,一切正常,但是,我想显示没有 firebase 名称的错误,我该怎么做?

使用错误代码捕获您的错误:

if(errorCode == "auth/email-already-in-use"){
    alert("Email already in use")
}
firebase.auth().createUserWithEmailAndPassword(email, password)
  .then((userCredential) => {
    // Signed in 
    var user = userCredential.user;
    // ...
  })
  .catch((error) => {
    if (error.code == "auth/email-already-in-use") {
        alert("The email address is already in use");
    } else if (error.code == "auth/invalid-email") {
        alert("The email address is not valid.");
    } else if (error.code == "auth/operation-not-allowed") {
        alert("Operation not allowed.");
    } else if (error.code == "auth/weak-password") {
        alert("The password is too weak.");
    }
  });