Google cloud firestore 与绑定的VuexFire同步不工作

Google cloud firestore 与绑定的VuexFire同步不工作,google-cloud-firestore,vuex,vuexfire,Google Cloud Firestore,Vuex,Vuexfire,我目前正在使用VuexFire将云Firestore绑定到我的Vuex状态。我在工作中遇到了一些问题,如有任何帮助,将不胜感激 我目前正在做的是: Vue.js文件: methods:{ ...mapActions("comments", ['bindArticleComments']), },created(){ this.bindArticleComments() }, 行动/评论文件 export const bindArticleCom

我目前正在使用VuexFire将云Firestore绑定到我的Vuex状态。我在工作中遇到了一些问题,如有任何帮助,将不胜感激

我目前正在做的是:

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状态字段执行相同的过程。在那里,它似乎没有任何问题。是否有人认为我做得不好?

奇怪的是,我让它工作了,尽管我很难理解它是如何工作的以及为什么工作的。在我的Vue js文件中,我在下载数据和创建时放置了this.bindArticleComments()

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()
  }

我自己在使用vuexfire绑定时遇到了一些奇怪的问题。在您的情况下,何时提取loadedArticle?