我使用Windows 8.我想用this guide.構建一個應用程序。在第7步,我更改main.js文件。我的文件內容如下:Firebase - 網絡聊天應用程序登錄按鈕不起作用
FriendlyChat.prototype.initFirebase = function() {
this.auth = firebase.auth();
this.database = firebase.database();
this.storage = firebase.storage();
this.auth.onAuthStateChanged(this.onAuthStateChanged.bind(this));
};
FriendlyChat.prototype.signIn = function(googleUser) {
var provider = new firebase.auth.GoogleAuthProvider();
this.auth.signInWithPopup(provider);
};
FriendlyChat.prototype.signOut = function() {
this.auth.signOut();
};
FriendlyChat.prototype.onAuthStateChanged = function(user) {
if (user) { // User is signed in!
var profilePicUrl = user.photoURL; // Only change these two lines!
var userName = user.displayName; // Only change these two lines!
....
}
FriendlyChat.prototype.checkSignedInWithMessage = function() {
if (this.auth.currentUser) {
return true;
}
....
我使用Firebase控制檯創建項目。點擊「將Firebase添加到您的網絡應用」,然後點擊該代碼段。我將它粘貼到index.html文件。文件內容如下:
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyAbtFJIZZxExBZec5XjsIE6p_TK4x-NDLE",
authDomain: "xxx-65704.firebaseapp.com",
databaseURL: "https://xxx-65704.firebaseio.com",
storageBucket: "xxx-65704.appspot.com",
};
firebase.initializeApp(config);
</script>
<script src="scripts/main.js"></script>
</body>
我在cmd終端上運行「firebase serve」命令。我打開本地主機:/ 5000and的頁面如下:
它不顯示網絡聊天。所以我打開we-start/index.html,點擊「使用Google登錄」。但我無法登錄,我不知道如何解決這個問題。我的錯誤是什麼?
我改變firebase.json在網上開始,但結果並沒有改變。新的含量低於:'「託管」:{ 「公」:「網絡啓動」, 「重寫「:[ { 」source「:」**「, 」destination「:」/index.html「 } ] }'' – zumma