我目前正在使用VuexFire将Cloud Firestore绑定到我的Vuex State。我有一些问题,使它的工作,任何帮助将不胜感激。
我目前正在做的事情如下:
Vue.js文件:
methods:{
...mapActions("comments", ['bindArticleComments']),
},created(){
this.bindArticleComments()
},操作/注释文件
export const bindArticleComments = firestoreAction(({ bindFirestoreRef }) => {
return bindFirestoreRef('articleComments', collectionRef('comments'))
})firebase服务文件
export const collectionRef = (collectionName) => {
return firestore().collection(collectionName)
}奇怪的是,我已经对不同的Vuex状态字段执行了相同的过程。在那里,它似乎工作得很顺利。有没有人认为我做得不对?
发布于 2020-12-04 07:08:56
奇怪的是,我让它工作了,尽管我很难理解在下载数据和创建数据后,我放置this.bindArticleComments()是如何以及为什么是working.In我的Vue js文件。
methods:{
downloadComments(){
const { articlesCommentRef } = this.$fb
articlesCommentRef(this.loadedArticle.id).get()
.then(querySnapshot => {
this.setArticleComments(querySnapshot.docs.map((doc) => doc.data()))
this.bindArticleComments(this.loadedArticle.id)})
.catch(error => console.log("Error getting documents: ", error))
.finally(() => {this.$q.loading.hide()})
}
},
created(){
this.bindArticleComments(this.loadedArticle.id)
},
mounted(){
this.downloadComments()
}https://stackoverflow.com/questions/65135370
复制相似问题