我创建了一个用于毕业研究的Web应用程序(由Vue-js,vue-router开发)。我正在使用Firebase身份验证登录。即使使用正确的电子邮件地址和密码,我也无法登录,并且站点从“ localhost:8080 / signin”重定向到“ localhost:8080 / signin?”
这是使用Vue(2.6.10)和firebase开发的。
(ellipsis)
input(type="text" placeholder="your@email.com" v-model="email")#MailAddress
(ellipsis)
input(type="password" placeholder="password" v-model="password")#Password
(ellipsis)
import firebase from "firebase";
export default {
name: "Signin",
data() {
return {
email: "",
password: ""
};
},
methods: {
signIn() {
firebase
.auth()
.signInWithEmailAndPassword(this.email, this.password)
.then(
() => {
alert("Success");
this.$router.push("/");
},
err => {
alert(err.message);
}
);
}
}
};
我希望重定向到'localhost:8080 /'
答案 0 :(得分:0)
这对我有用。
在我的Vue组件中:
import firebase from '../database';
async signIn () {
let result = await firebase.signIn(this.email, this.password);
if (result.message) {
this.error = result.message;
} else {
// Go to your route
}
}
在我的数据库文件中:
const database = firebase.initializeApp(config);
database.signIn = async (email, password) => {
try {
await firebase.auth().signInWithEmailAndPassword(email, password);
return true;
} catch (error) {
return error;
}
};