2017-04-01 76 views
0

我有類似於this的問題,除了我使用this的聚合物模板。Polymerfire - 無法讀取未定義的屬性'推'

我在聲明<firebase-app>的頁面以及使用<firebase-query>的頁面中導入了所有聚合物引用參考文獻。不工作。

我後來發現該模板使用了聚合火焰,其版本是v0.9.4而不是最新的v0.10.3。我試着卸載並重新安裝新版本。沒有改變。

有關更多的信息,這裏的代碼片段:

的src/APP-auth /中應用認證 - firebase.html

<link rel="import" href="../../bower_components/polymerfire/polymerfire.html"> 
<link rel="import" href="../../bower_components/polymerfire/firebase-app.html"> 
<link rel="import" href="../../bower_components/polymerfire/firebase-auth.html"> 
<link rel="import" href="../../bower_components/polymerfire/firebase-query.html"> 
... 
<firebase-app name="pwa-demo" api-key="abc" auth-domain="abc" database-url="abc"></firebase-app> 

<firebase-auth id="auth" app-name="pwa-demo" signed-in="{{_signedIn}}" user="{{_user}}"on-error="_onAuthError"></firebase-auth> 

的src/APP-頁/ APP-頁新的東西/應用程序頁面,新stuff.html

<link rel="import" href="../../../bower_components/polymerfire/firebase-auth.html"> 
<link rel="import" href="../../../bower_components/polymerfire/firebase-query.html"> 
<link rel="import" href="../../../bower_components/polymerfire/polymerfire.html"> 
... 
<firebase-auth user="{{user}}"></firebase-auth> 

<firebase-query id="stuffquery" app-name="pwa-demo" path="https://stackoverflow.com/users/[[user.uid]]/events" data="{{events}}"> </firebase-query> 
... 
_onFormSubmit: function() { 
    this.$.stuffquery.ref.push({ 
     title: this.$.piTitle.value 
    }); 
} 

還有什麼我失蹤?請幫忙。

編輯: 我發現了另外兩個奇怪的東西,這可能會有幫助。首先,我無法同時檢索數據和將數據從我的應用程序推送到應用程序。其次,當我試圖在瀏覽器控制檯中運行firebase.database()時,我得到"Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)."

有人嗎?

回答

2

經過幾天的挫折,它的工作。顯然。

TL; DR

我所做的是更新polymerfire並忽略任何火力元素的name屬性。

說明

看着this,似乎在火力方法__computeApp初始化程序和名稱是一個可選的變量,但如果提供,將在初始化時使用。忽略它,一切都應該沒問題。在我的情況下,既適用<firebase-app><firebase-auth><firebase-query>(推送數據,因爲我仍然停留在​​)

雖然它在我的情況下,它可能不一定是正確的解決方案。它可能不適用於你的情況。花了我好幾天的時間才弄清楚,所以對於那些遇到類似問題的人來說,其中一個可能有所幫助:

  1. 檢查firebase查詢屬性。請參閱this
  2. 嘗試在聲明<firebase-app>的相同html文件中導入polymerfire/polymerfire.html。參考this
  3. 更新聚合物燃燒。只需卸載並重新安裝它即可解決此案(對於使用過時版本的聚合火焰)
  4. 忽略來自任何firebase元素的name屬性。我知道我的<firebase-app>已成功初始化,當我在瀏覽器控制檯中輸入firebase.database()時,它不會再出現錯誤。

希望它有幫助。

相關問題