【发布时间】:2019-09-10 18:48:08
【问题描述】:
我是 firebase 新手,我正在尝试创建一个壁纸应用。我想从看起来像这样的数据库中检索数据。
。但它不止两个层次。我想显示男孩组和女孩组的详细信息,但不显示他们的名字。我想这样展示
如果我不添加级别的男孩组和女孩组,我可以做我想做的事,但我需要这些作为类别。它是三个级别的值,这让我很困惑如何一次性检索男孩组的孩子和女孩组的孩子。 这是两级孩子的代码..请帮助我
var dbCategories = firebase.database().ref("categories");
dbCategories.on("value",function(categories){`
if (categories.exists()) {
var categorieshtml = "";
categories.forEach( function(category) {
// statements
var newCategory =category.val();
console.log(category);
categorieshtml += "<tr>";
//for category name
categorieshtml += "<td>";
categorieshtml += category.key;
console.log(categorieshtml);
categorieshtml += "</td>";
//for category Description
categorieshtml += "<td>";
categorieshtml += category.val().desc;
console.log(categorieshtml);
categorieshtml += "</td>";
//for category Thumbnail
categorieshtml += "<td> <img width='250' height='150' src='";
categorieshtml += category.val().thumbnail;
categorieshtml += "'/></td>";
categorieshtml += "</tr>";
});
$("#categories").html(categorieshtml);
}
【问题讨论】:
标签: javascript html firebase firebase-realtime-database web-applications