
var dbImages = firebase.database().ref("images");
dbImages.on("value", function(images){
if(images.exists()){
var imageshtml = "";
images.forEach(function(fetchImages){
console.log("key: " fetchImages.key);
console.log("title: " fetchImages.title);
console.log("url: " fetchImages.url);
});
}
});
它只顯示鍵值而不是其他值我想查看鍵值以及鍵值的值請幫助大家

uj5u.com熱心網友回復:
您正在使用forEach()and DataSnapshotof/orders節點,其中每個子節點似乎是一個類別而不是影像本身。您必須遍歷類別的每個影像以列出它們:
firebase.database().ref("images").once("value").then((imagesCategories) => {
if (imagesCategories.exists()) {
var imageshtml = "";
// For each category
imagesCategories.forEach(function(categoryImages) {
// For each category image
categoryImages.forEach(function(image) {
// Append data to imageshtml from here
console.log(image.val().url)
console.log(image.val().title)
})
})
}
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/455015.html
標籤:javascript 火力基地 firebase-实时数据库
下一篇:從嵌套的JSON中獲取資料
