【问题标题】:Using firestore() in a method在方法中使用 firestore()
【发布时间】:2018-05-06 06:06:39
【问题描述】:

我正在尝试从 Google Cloud Firestore 加载数据。我可以加载整组数据OK,但是我不能调用一个方法并获取一条记录。

Vue-firestore 来自 https://github.com/gdg-tangier/vue-firestore,但文档并未涵盖这一点。

这行得通

new Vue({
  el : '#app',

  ...

  firestore() {
    return {
        pages: db.collection('pages')
        }
    },

这不是

methods: {

    showPage: function(id) {
        console.log("Getting content for: " + id);

        firestore() { return { page : db.collection('pages').where("title", "==", id) } };
        console.log(JSON.stringify(this.page));
        },

firestore() 是如何设置的?

【问题讨论】:

    标签: firebase vue.js google-cloud-firestore


    【解决方案1】:

    我误解了firestore() 的作用。

    firestore() 不是对正在运行的数据库的调用。它更像是建立一个之前分配给 db 的连接。

    这不起作用的原因是,已经有一个连接,db。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-10
      • 2021-12-13
      • 2021-04-27
      • 2018-12-22
      • 2020-07-08
      • 2021-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多