【发布时间】:2020-10-02 05:01:26
【问题描述】:
无法在 Firebase 数据库中创建用户请帮助或 告诉我有关此问题的文档。 是不是笔画user_id: cred.user.uid ?
methods: {
signup(){
if(this.alias && this.email && this.password){
this.feedback = null
this.slug = slugify(this.alias, {
replacement: '-',
remove: /[$*_+~.()'"!\-:@]/g,
lower: true
})
let ref = db.collection('users').doc(this.slug)
ref.get().then(doc => {
if(doc.exists){
this.feedback = 'This alias already exists'
} else {
// this alias does not yet exists in the db
firebase.auth().createUserWithEmailAndPassword(this.email, this.password)
.then(cred => {
ref.set({
alias: this.alias,
geolocation: null,
user_id: cred.user.uid
})
}).then(() => {
this.$router.push({ name: 'GMap' })
})
.catch(err => {
this.feedback = err.message
})
}
})
} else {
this.feedback = 'Please fill in all fields'
}
}
}
【问题讨论】:
-
你必须测试它,
console.log(cred)如果我是,我会为我要添加到数据库中的信息创建一个新函数,这样使用它是不好的。例如 saveUserDatabase({this.alias,null,cred.user.uid}) -
看起来是正确的。 devtools 控制台中是否有任何错误消息?
-
否,但未创建数据库(
标签: javascript node.js firebase vue.js google-cloud-firestore