【问题标题】:How to GET the id of the post in Firebase with Vue js如何使用 Vue js 在 Firebase 中获取帖子的 ID
【发布时间】:2020-04-22 17:19:45
【问题描述】:

我想打印帖子 ID 的 ID。我使用 Vue js。我使用实时数据库。

【问题讨论】:

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


    【解决方案1】:

    如果你使用的是 vuefire

    item['.key'] 可以轻松工作

    例子:

    <li v-for="item in items"> {{item['.key']}} </li>
    

    在您设置配置和设置数据库引用之后。

    在您的组件的&lt;script&gt; 中添加firebase(option),如下所示

      firebase: {
        items: db.ref('items'),
      },
    

    【讨论】:

    • 我得到了它&lt;div class="col-sm-12 mt-5" v-if="item['.key'] == route"&gt; 然后我查看了文档并尝试了这个并且它有效route: this.$route.params.id
    猜你喜欢
    • 2023-01-18
    • 2022-10-13
    • 2014-03-12
    • 2022-11-23
    • 2016-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多