2017-04-17 29 views
2

我試圖將數據保存到firebase數據庫中,但始終遇到TypeError。似乎無法找到問題所在。這裏是我的<template>代碼:使用Polymerfire保存文檔中的問題

<firebase-auth 
    id="auth" 
    app-name="notes" 
    provider="google" 
    signed-in="{{signedIn}}" 
    user="{{user}}"> 
</firebase-auth> 

<firebase-document 
    id="document" 
    app-name="notes" 
    path="[[editableNoteId]]" 
    data="{{editableNote}}"> 
</firebase-document> 

<na-editor 
    id="editor" 
    note="{{editableNote}}" 
    on-close="commitChange"> 
</na-editor> 

腳本:

<script> 
    Polymer({ 
    is: 'note-app', 

    behaviors: [Polymer.NoteAppBehavior], 

    signIn: function() { 
     this.$.auth.signInWithPopup(); 
    }, 

    get notesPath() { 
     return '/notes/' + this.user.uid; 
    }, 

    toEditableId: function(noteId) { 
     return this.notesPath + '/' + noteId; 
    } 
    }); 
</script> 

以下是錯誤:

TypeError: this.$.document.save is not a function. (In 'this.$.document.save(this.notesPath)', 'this.$.document.save' is undefined) 

注:該應用程序名稱和火力點,應用程序是否已經正確定義。

+0

我也是從Android應用程序,但沒有試圖發生同樣的代碼是工作今天,當我去安慰數據庫沒有加載可能是他們的服務器關閉或別的東西發生 –

回答

3

0.11.0版本中,save()方法被重命名爲saveValue()以維持與某些JS編譯器和舊瀏覽器的兼容性。詳情請參閱the release notes

docs現在也顯示更新,但可能不是當你看着它們。

+0

太謝謝你了。這解決了這個問題。它在4天前更新,所以我想我錯過了它。 – user7877939

1

將此添加到腳本解決了問題。

save: function() {  
    this.$.document.saveValue(); 
},