【发布时间】:2016-04-13 11:51:33
【问题描述】:
我正在尝试从 firebase 数据库中获取结果并显示所有结果。当我可以使用 appendTo 函数时,与 jquery 不同,我不知道如何使用纯 javascript 完成它。
这是我的脚本:
<div id="resultsContainer"></div>
var fireBaseRef = new Firebase("https:somefirebaseurl.firebaseio.com/results");
fireBaseRef.once("value", function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var key = childSnapshot.key();
// childData will be the actual contents of the child
var childData = childSnapshot.val();
var eName = childSnapshot.val().resultname;
console.log(eName);
resultsContainer.innerHTML = '<div class="result"></div>';
});
});
如您所见,我使用了 innerHTML,但这只给了我一个结果集。
【问题讨论】:
标签: javascript firebase firebase-realtime-database