繁体   English   中英

如何生孩子-Firebase

[英]How to get child - Firebase

如何获得名字的孩子

在此处输入图片说明

const ref = firebase.database().ref('order/');
const dbref = ref.child('items');

ref.on('child_added', data =>  {
    console.log(data.key, data.val().name);
});

您的代码:

const ref = firebase.database().ref('order/');
const dbref = ref.child('items');

设置对/order/items的引用。 您显示的数据中没有这样的位置。

您想要的是:

const ref = firebase.database().ref('order/');

ref.on('child_added', snapshot =>  {
    // snapshot now contains the data of -KmDWQ...
    snapshot.child("items").forEach((itemSnapshot) => {
        console.log(itemSnapshot.key, itemSnapshot.val().name);
    });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM