【问题标题】:Vuefire dynamic pathVuefire动态路径
【发布时间】:2018-07-07 01:22:51
【问题描述】:

如何为 vuefire 设置路径,如下所示

export default {
  firebase: {
    classlist: db.ref('chapter/1'),  // here 1  need to be taken from data
    // like this db.ref('chapter/' + this.chapterid),
  },
  data:{
     chapterid:'' 
  },
  mounted:{
  // getchapterid here  
  this.chapterid=getChapterId()

  }
}

它不起作用,它返回错误 undefined chapterid ,有什么办法吗?

【问题讨论】:

    标签: firebase firebase-realtime-database vue.js vuejs2 vuefire


    【解决方案1】:

    对firebase使用函数语法,否则this不会绑定到vue实例。

    firebase() {
      return {
       classlist: db.ref('chapter/' + this.chapterid)
      }
    },
    


    来源:https://github.com/vuejs/vuefire/issues/90

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-14
      • 1970-01-01
      • 2022-07-12
      • 2022-01-04
      • 1970-01-01
      • 2020-01-10
      • 2018-05-03
      • 2014-01-10
      相关资源
      最近更新 更多