2017-04-17 33 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(); 
},