我试图通过执行此操作来显示Firebase中特定表格中的所有数据
此表中总共有4个数据,p1 - p4,但它只显示1个结果。
JS:
var ref = firebase.database().ref().child(uid + '/pickUp');
var query = ref.orderByKey().limitToLast(100);
query.on("child_added", function(messageSnapshot) {
var keys = Object.keys(messageSnapshot);
var messageData = messageSnapshot.val();
var key = messageSnapshot.getKey();
console.log("key is " + messageSnapshot.getKey());
console.log("messagesnapshot is " + messageSnapshot);
console.log("messageData is " + messageData);
s = "<div><input type='text' name='pickUp[]' value='messageData'>" + key + "</div>";
var obj = {
key: key,
};
arr.push(obj);
$("#container1").html(s);
console.log("arr.length is " + arr.length);
});
HTML:
<label for="basic">Pick Up Location:</label>
<div id="container1">
</div>
结果:
答案 0 :(得分:1)
使用append()而不是html()
...
$("#container1").append(s);