【发布时间】:2020-12-12 11:02:33
【问题描述】:
我正在尝试将 Firebase 数据库中的数据显示到 html 文档中。在下面你可以看到我的 HTML 和 JavaScript 文件。我对 Firebase 很陌生,所以我很可能犯了一个错误。感谢所有答案!
提前致谢!
HTML:
<p id="profile"></p>
<table id="profiledetails-table">
<tr id="tr">
<th>Name</th>
<th>Email</th>
</tr>
</table>
Javascript:
firebase.auth().onAuthStateChanged(function(user) {
var docRef = db.collection('users').doc(firebase.auth().currentUser.uid)
docRef.get().then(function(snapshot) {
if (doc.exists) {
console.log("Document data:", doc.data());
$('#profiledetails-table').append(doc.data);
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
})
});
【问题讨论】:
标签: javascript html firebase firebase-realtime-database