答案 0 :(得分:2)
createUserWithEmailAndPassword()
方法返回一个UserCredential
,如doc中所述。 UserCredential
的{{3}}解释说,它包含一个User
对象。
因此,您应该执行以下操作。
signup() {
this.performingRequest = true
fb.auth.createUserWithEmailAndPassword(this.signupForm.email, this.signupForm.password).then(userCredential => {
this.$store.commit('setCurrentUser', userCredential.user) //Or userCredential, depending on what you want to save.
// create user obj
fb.usersCollection.doc(userCredential.user.uid).set({
name: this.signupForm.name,
email: this.signupForm.email
}).then(() => {
this.$store.dispatch('fetchUserProfile')
this.performingRequest = false
this.$router.push('/world')
}).catch(err => {
console.log(err)
this.performingRequest = false
this.errorMsg = err.message
})
}).catch(err => {
console.log(err)
this.performingRequest = false
this.errorMsg = err.message
})
},
答案 1 :(得分:0)
将user.uid转换为String:
fb.usersCollection.doc(String(user.uid))