首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bind不工作时的VuexFire同步

bind不工作时的VuexFire同步
EN

Stack Overflow用户
提问于 2020-12-04 06:49:39
回答 1查看 100关注 0票数 0

我目前正在使用VuexFire将Cloud Firestore绑定到我的Vuex State。我有一些问题,使它的工作,任何帮助将不胜感激。

我目前正在做的事情如下:

Vue.js文件:

代码语言:javascript
复制
  methods:{
    ...mapActions("comments", ['bindArticleComments']),
 },created(){
    this.bindArticleComments()
  },

操作/注释文件

代码语言:javascript
复制
  export const bindArticleComments = firestoreAction(({ bindFirestoreRef }) => {
    return bindFirestoreRef('articleComments', collectionRef('comments'))
  })

firebase服务文件

代码语言:javascript
复制
export const collectionRef = (collectionName) => {
  return firestore().collection(collectionName)
}

奇怪的是,我已经对不同的Vuex状态字段执行了相同的过程。在那里,它似乎工作得很顺利。有没有人认为我做得不对?

EN

回答 1

Stack Overflow用户

发布于 2020-12-04 07:08:56

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

代码语言:javascript
复制
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()
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65135370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档