【问题标题】:Firebase Real time database won't workFirebase 实时数据库不起作用
【发布时间】:2016-08-28 23:22:15
【问题描述】:

我跟踪了Getting started with firebase on the web中的每个流程 视频教程。这是我看完教程后写的代码。

<h1 id="one"></h1>


<script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>
<script>
  // Initialize Firebase
  var config = {
    apiKey: "AIzaSyCMhmAMbUwmZLQFG9EZLgnbmOJVabdfNvU",
    authDomain: "test-24e84.firebaseapp.com",
    databaseURL: "https://test-24e84.firebaseio.com",
    storageBucket: "test-24e84.appspot.com",
  };
  firebase.initializeApp(config);

  var one = document.getElementsById('one');
  var dbref = firebase.database().ref().child('text');
  dbref.on('value', snap => one.innerText = snap.val());
</script>

编写代码后,我在我的 chrome 浏览器中执行了 html 文件。但是,我在屏幕上看不到任何文字。(它只是空白,没有区别)

怎么了?我怎样才能让代码运行?

【问题讨论】:

    标签: javascript firebase firebase-realtime-database


    【解决方案1】:

    失败是因为document.getElementsById 不是函数;这是document.getElementById

    【讨论】:

      猜你喜欢
      • 2021-11-13
      • 1970-01-01
      • 2021-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2021-02-27
      相关资源
      最近更新 更多