页面自动刷新?。
曾尝试在服务器和本地以及从文件中运行页面。
<button class="uk-button uk-button-primary" id="sin">hello</button>
<button class="uk-button uk-button-primary" id="sout">logout</button>
</div>
</fieldset>
</form>
</div>
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-auth.js"></script>
<script>
var firebaseConfig = {
//this part does its job fine
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var sout = document.getElementById('sout');
var sin = document.getElementById('sin');
sin.addEventListener('click', () => {
console.log("click1");
let email = document.getElementById('email').value;
let pass = document.getElementById('pass').value;
firebase.auth().signInWithEmailAndPassword(email, pass).then(()=>{
console.log("sucessfull");
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(errorMessage);
});
});
sout.addEventListener('click', () => {
console.log("click1");
firebase.auth().signOut().then(function () {
console.log("Sign-out successful");
}).catch(function (error) {
console.log(error);
});
});
</script>
控制台日志必须保留,但不能保留。 尝试对每一行进行断点操作,似乎控制台日志可以正常工作,但是在页面末尾,它们消失了,重新加载浏览器。