首页 > 解决方案 > 使用 Firebase 中的多个数据附加列表 - JavaScript

问题描述

所以我想从 Firebase 数据库中获取多个数据,然后我希望将数据附加到我的 HTML 页面中的列表中。如果有人可以帮助我解决下面代码中的问题,或者他们是更好的选择。将不胜感激。

function listitem() {
  var ref = firebase.database().ref("/Users/" + uid + "/todo");
  ref.once("value", (snapshot) => {
    snapshot.forEach((childSnapshot) => {
  var childKey = childSnapshot.key;
  var childData = childSnapshot.val();
  console.log(childKey);
  console.log(childData);
  });
 });
}

//append list of items
function loadlist() {
 var node = document.createElement("LI");
 var textnode = document.createTextNode(listitem());
 node.appendChild(textnode);
 document.getElementById("toDoList").appendChild(node);
}

标签: javascripthtmllistfirebase

解决方案


推荐阅读