Firebase网站:无法填充列表

时间:2019-01-23 18:16:14

标签: javascript firebase firebase-realtime-database

我似乎找不到与Firebase for Web有关的类似问题。我度过了愉快的时光,动态地为Firebase数据库中的数据设置文本标签。但是由于某种原因,我无法填充列表。

这是我的数据库:

{
"\"boxHeadings\"" : {
"boxFooter" : "Okbye",
"boxHeading1" : "Box Heading 1",
"boxHeading2" : "Box Heading 2"
},
"blueBox" : "Box Header",
"boxBody" : "Box Body",
"boxFooter" : "Box Footer"
}

这是我的HTML中的部分(请注意最后的ul)。我知道我可能只是向您展示了ul,但只是希望您在上下文中看到它:

<section class="content container-fluid" id="fireSection">

        <pre id="object"></pre>
        <div class="box box-solid box-primary">
          <div class="box-header with-border">
            <h3 id="fireBoxHeading" class="box-title"></h3>
            <div class="box-tools pull-right">

              <!-- Here is a label for example -->
              <span class="label label-primary">Label</span>
            </div>
            <!-- /.box-tools -->
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <p id="fireBoxBody"></p>
          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <p id="fireBoxFooter"></p>
          </div>
          <!-- box-footer -->
        </div>
        <!-- /.box -->

        <ul class="list-group" id="demo-list">

        </ul>

</section>
<!-- /.content -->

这是我的JS(我在文件中包含了Firebase配置代码,它可以在我正在做的其他innerTexts上使用。)

var ulist = document.getElementById("demo-list");

var dbRef = firebase.database().ref().child("boxHeadings");
dbRef.on('child_added', snapshot => {
var li = document.createElement('li');
li.innerText = snapshot.val();
li.id = snapshot.key;
ulist.appendChild(li);
});

不确定为什么什么也没发生。控制台中也没有错误。任何提示将不胜感激。谢谢!

0 个答案:

没有答案
相关问题