我们如何将Firebase Hosting与Firebase实时数据库/存储集成?

时间:2016-10-22 05:09:39

标签: firebase firebase-realtime-database firebase-storage firebase-hosting

现在Firebase提供了虚拟主机服务,我们如何将Firebase托管与Firebase实时数据库和Firebase存储集成?

1 个答案:

答案 0 :(得分:2)

Firebase Hosting是您的网络应用程序的静态托管。因此您可以使用HTML,CSS,JavaScript。

JavaScript代码:

<script src="https://www.gstatic.com/firebasejs/3.5.0/firebase.js"></script>
<script>
  // Initialize Firebase
  // TODO: Replace with your project's customized code snippet
  var config = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
    messagingSenderId: "<SENDER_ID>",
  };
  firebase.initializeApp(config);

  // Get a reference to the database service
  var database = firebase.database();


 // Get a reference to the storage service, which is used to create
 references in your storage bucket

  var storage = firebase.storage();

</script>

更多请参阅: