Firebase,登录后如何重定向?
我正在学习如何在一个大学项目中使用Firebase,但我对JS的了解很低,而且我遇到了一些问题。我想要的是,登录正确后,用户应该重定向到X站点,但我不知道如何做。这就是我目前拥有的:Firebase,登录后如何重定向?,firebase,firebase-authentication,Firebase,Firebase Authentication,我正在学习如何在一个大学项目中使用Firebase,但我对JS的了解很低,而且我遇到了一些问题。我想要的是,登录正确后,用户应该重定向到X站点,但我不知道如何做。这就是我目前拥有的: const inputEmail = document.getElementById('inputEmail'); const inputPassword = document.getElementById('inputPassword'); const btnIniciarSesion = document.ge
const inputEmail = document.getElementById('inputEmail');
const inputPassword = document.getElementById('inputPassword');
const btnIniciarSesion = document.getElementById('btnIniciarSesion');
btnIniciarSesion.addEventListener('click', e => {
const email = inputEmail.value;
const password = inputPassword.value;
const auth = firebase.auth();
const promise = auth.signInWithEmailAndPassword(email, password);
promise.catch(e => console.log(e.message));
});
有什么建议吗?试试这个:
auth.signInWithEmailAndPassword(email, password)
.then(user => {
// Sign in success
// Route to site here
}).catch(error => {
console.error(error);
})
我可以用java解释这一点,对您来说可以吗?因为要做到这一点,您需要使用AuthListener,当firebase.auth!=空你可以做一个意图然后去X地点谢谢Eric!工作完美,现在我的登录表单在登录成功时重定向:)