我想从firebase检索数据并显示在我尝试了大多数方法的网站上,但不适用于我。
这是我的火力发源地
"transactions" : {
"8527z732x5e5RZnaWlYnvXLQv1Z2" : {
"102" : {
"trans_amount" : "20",
"trans_date" : "23/11/2018"
},
"103" : {
"trans_amount" : 240,
"trans_date" : "23/12/2018"
}
},
"WfEQmVDBXeXFqrmzNslIPhD0UqQ2" : {
"102" : {
"trans_amount" : "20",
"trans_date" : "23/11/2018"
}
}
}
这是我的检索代码
ref.on("child_added", function (snapshot) {
PrintData.innerText = ""; // We got a new value, so clear the existing
HTML
snapshot.forEach(function (childSnapshot) {
var childData = childSnapshot.val();
//showing single object value
console.log(childData);
PrintData.innerText += "trans_amount: " + childData.trans_amount + "
trans_date: " + childData.trans_date + "
";
});
});
这是我的输出