【发布时间】:2020-08-12 09:00:49
【问题描述】:
在检索 firebase 数据库值时,这些值是重复的,我不知道为什么控制台只显示我的数据库中的 4 个值 take a look at this.
var ref = firebase.database().ref("users");
ref.on("value", function(data){
$('#table').empty()
var content = '';
data.forEach(function(childSnapshot){
if (childSnapshot.exists()){
var id = childSnapshot.key;
var childData = childSnapshot.val();
console.log(childData);
console.log(id);
content +='<tr>';
content += '<td>' + childData.username + '</td>';
content += '<td>' + childData.phone + '</td>';
content += '</tr>';
};
$('#table').append(content);
});
});
【问题讨论】:
标签: html node.js firebase firebase-realtime-database