Firebase auth函数运行两次.Vue js



使用Firebase createUserWithEmailAndPassword创建用户时。函数运行两次。这就是为什么,它给出了电子邮件已经在使用的错误。vue js 2和firebase 9中的应用程序。

async registerForm(){
const auth = getAuth()
const user = await createUserWithEmailAndPassword(auth, this.email, this.password)
.then(userCredential => {
this.userId = userCredential.user.uid
console.log(this.userId);
this.x++
})
.catch(error => {
console.log(error);
})
console.log('user signed up', this.x);
this.$router.replace({name: 'home'})**
}

路由重定向中可能存在问题,如果您在渲染端找到了auth函数,当您更改路由或移动到另一个路由时,您将再次渲染组件,这可能是调用两次函数的原因

最新更新