HTML
Email : <input type="email" id="txtEmail"><br>
Password : <input type="password" id="txtPassword"><br>
<button id="btnLogin">Log In</button>
<button id="btnSignUp">Sign Up</button>
JS
document.getElementById('btnLogin').addEventListener('click',e => {
//get Email and Pass
const email = document.getElementById('txtEmail');
const pass = document.getElementById('txtPassword');
const auth = firebase.auth();
const promise = auth.signInWithEmailAndPassword(email,pass);
promise.catch(e => console.log(e.message));
});
出现以下错误:
第一个参数“ email”必须为有效的字符串。
答案 0 :(得分:0)
将代码中的以下代码段更改为:
const email = document.getElementById('txtEmail').value;
const pass = document.getElementById('txtPassword').value;