Firebase Vuefire动态路径

Firebase Vuefire动态路径,firebase,firebase-realtime-database,vue.js,vuejs2,vuefire,Firebase,Firebase Realtime Database,Vue.js,Vuejs2,Vuefire,如何设置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 he

如何设置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使用函数语法,否则
不绑定到vue实例

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

资料来源: