[Vuejs]-VueJS + Firebase Using the Firebase Binding

0👍

names is not defined on the vue. Define it in the data method. Once that’s done, realize that the firebase ref is not array-like; so iteration doesn’t make sense. It must be "listened to" with the on() method…

import {db} from '@/firebase'

data() {
  return {
    names: null,
  }
},
mounted () {
  db.ref('names').on('value', dataSnapshot => {
    this.names = dataSnapshot.val()
  })
},

With this, the markup can iterate v-for="name in names"

Leave a comment