0

所以我正在尝试使用 vuefire 和 vue 在列表中显示基本数据,但是 items 对象为空这是列表 items.vue 文件

<template>
  <div>
    <h1>List Item</h1>
    <table class="table table-striped">
      <thead>
        <tr>
          <th>Item Name</th>
          <th>Item Price</th>
          <th colspan="2">Action</th>
        </tr>
      </thead>
      <tbody>
          <tr v-for="item of items" :key="item['.key']">
            <td>{{ item.name }}</td>
            <td>{{ item.surname }}</td>
      </tbody>
    </table>
  </div>
</template>

<script>

import { db } from '../config/db';

export default {
  components: {
      name: 'ListItem'
  },
  data() {
    return {
      items: []
    }
  },
  firebase: {
    items: db.ref('drivers')
  },
  }
}
</script>
import Firebase from 'firebase'

const firebaseConfig = {
        apiKey: "",
        authDomain: "",
        databaseURL: "",
        projectId: "",
        storageBucket: "",
        messagingSenderId: "",
        appId: ""
};
so this is my db.js file 
let app = Firebase.initializeApp(firebaseConfig)
export const db = app.database()

列表项似乎是空的并且没有显示数据,我相信它可能与 db.ref(drivers) 有关,但我正在使用插入函数并且有效,数据库已经有 5 个条目

4

1 回答 1

0

你添加插件了吗?(firestorePlugin在火库的情况下)

import { rtdbPlugin } from 'vuefire';

Vue.use(rtdbPlugin);

还有,是drivers收藏吗?那时应该是db.collection('drivers')

于 2019-08-14T08:41:18.573 回答