![](/img/trans.png)
[英]How to Add Child on Firebase and then Get it and Display the information?
[英]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.