0

我剛剛將the new Polymerfire <firebase-app> element添加到我的(Polymer 1.x + Firebase 3.x)項目中,並且它崩潰了該項目。我期望看到主屏幕上的本地主機加載,但是,我只是得到一個空白屏幕和控制檯錯誤。Polymerfire <firebase-app>元素崩潰應用程序

我-element.html
<firebase-app auth-domain="my-app-id.firebaseapp.com" 
       database-url="https://my-app-id.firebaseio.com/" 
       api-key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> 
</firebase-app> 

控制檯日誌報告以下錯誤:

CONSOLE.LOG

firebase-app.html:94
Uncaught ReferenceError: firebase is not defined

的代碼(行號94)相關線上如下:

firebase-app.html,line 94
firebase.initializeApp.apply(firebase, init); // Line 94, highlighted error 

The entire source code for the firebase-app element is located here

https://github.com/firebase/polymerfire/blob/master/firebase-app.html從評論
<!-- 
@license 
Copyright 2016 Google Inc. All Rights Reserved. 
Use of this source code is governed by a BSD-style 
license that can be found in the LICENSE file or at 
https://github.com/firebase/polymerfire/blob/master/LICENSE 
--> 

<link rel="import" href="../polymer/polymer.html"> 
<link rel="import" href="firebase.html"> 
<dom-module id="firebase-app"> 
    <script> 
    (function() { 
     'use strict'; 
     /** 
     * The firebase-app element is used for initializing and configuring your 
     * connection to firebase. 
     */ 
     Polymer({ 
     is: 'firebase-app', 
     properties: { 
      /** 
      * The name of your app. Optional. 
      * 
      * You can use this with the `appName` property of other Polymerfire elements 
      * in order to use multiple firebase configurations on a page at once. 
      * In that case the name is used as a key to lookup the configuration. 
      */ 
      name: { 
      type: String, 
      value: '' 
      }, 
      /** 
      * Your API key. 
      * 
      * Get this from the Auth > Web Setup panel of the new 
      * Firebase Console at https://console.firebase.google.com 
      * 
      * It looks like this: 'AIzaSyDTP-eiQezleFsV2WddFBAhF_WEzx_8v_g' 
      */ 
      apiKey: { 
      type: String 
      }, 
      /** 
      * The domain name to authenticate with. 
      * 
      * The same as your Firebase Hosting subdomain or custom domain. 
      * Available on the Firebase Console. 
      * 
      * For example: 'polymerfire-test.firebaseapp.com' 
      */ 
      authDomain: { 
      type: String 
      }, 
      /** 
      * The URL of your Firebase Realtime Database. You can find this 
      * URL in the Database panel of the Firebase Console. 
      * Available on the Firebase Console. 
      * 
      * For example: 'https://polymerfire-test.firebaseio.com/' 
      */ 
      databaseUrl: { 
      type: String 
      }, 
      /** 
      * The Firebase app object constructed from the other fields of 
      * this element. 
      */ 
      app: { 
      type: Object, 
      notify: true, 
      computed: '__computeApp(name, apiKey, authDomain, databaseUrl)' 
      } 
     }, 
     __computeApp: function(name, apiKey, authDomain, databaseUrl) { 
      if (apiKey && authDomain && databaseUrl) { 
      var init = [{ 
       apiKey: apiKey, 
       authDomain: authDomain, 
       databaseURL: databaseUrl 
      }]; 
      if (name) { 
       init.push(name); 
      } 
      firebase.initializeApp.apply(firebase, init); 
      } else { 
      return null; 
      } 
      return firebase.app(name); 
     } 
     }); 
    })(); 
    </script> 
</dom-module> 
+1

我只是git克隆你的項目,涼亭更新和polyserve,它適用於我。去檢查你的涼亭組件,看看你是否有firebase-sdk/index.js火,如果它包含JavaScript。 –

+0

@ Bogdan.Nourescu:等等。什麼?我們需要下載firebase-sdk/index.js?你怎麼知道的?爲什麼它不與Polymerfire捆綁在一起?通常,我們只需使用bower命令「安裝」不同的元素(例如,'bower install --save PolymerElements/paper-button'),並且所有依賴項都會與該單一命令一起安裝。我很困惑。請幫忙。 – Mowzer

+1

好吧...在bower.json中,您有依賴項中的firebase-sdk。它已經在那裏了,所以'bower update'應該將它安裝在你本地的bower_components文件夾中。請檢查您的項目中是否有bower_components文件夾,並檢查其中是否有firebase-sdk/index.js文件。我的猜測是你沒有運行更新。 –

回答

1

摘要:@ Bogdan.Nourescu是正確的。我沒有正確安裝firebase-sdk目錄。

我必須安裝使用鮑爾使用以下命令Polymerfire依賴關係:

bower install --save firebase/polymerfire 

注:bower install --save polymerfire點DivShot的版本,這是現在已經過時。