如何在Firebase Javascript中获取子项的价值? [英] How to get the value of children in Firebase Javascript?

查看:82
本文介绍了如何在Firebase Javascript中获取子项的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的Firebase数据库:

This is my Firebase Database:

我需要与push方法生成的唯一随机名称相关联的图像的URL。有什么办法可以吗?此外,必须存在更好的数据发送方式。请告诉我。谢谢。

I need the URLs of the images that are associated alongside the unique random name generated by the push method. Is there any way I could do that? Also, there must exist a better way of sending data. Please, let me know. Thanks.

imgRef.on('value', function(snapshot) {
console.log(snapshot.val());
});

正如预期的那样,返回整个JSON对象。我需要URL。

This is, as expected, returning the entire JSON object. I need the URL.

推荐答案

这是显示图片网址列表的最基本方式:

This is the most basic way to show the list of image URLs:

var rootRef = firebase.database.ref();
var urlRef = rootRef.child("user1/DAA Notes/URL");
urlRef.once("value", function(snapshot) {
  snapshot.forEach(function(child) {
    console.log(child.key+": "+child.val());
  });
});

这篇关于如何在Firebase Javascript中获取子项的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆