问题
Now that Firebase provides Web Hosting services, how can we integrate Firebase Hosting with Firebase Realtime Database and Firebase Storage?
回答1:
Firebase Hosting is static hosting for your web app.So you can use HTML, CSS, JavaScript.
JavaScript Code:
<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>
For More See:
- https://firebase.google.com/docs/web/setup
- https://firebase.google.com/docs/hosting/
来源:https://stackoverflow.com/questions/40188552/how-can-we-integrate-firebase-hosting-with-firebase-realtime-database-storage