聚合物paper-button syntaxerror函数语句需要一个名称

ste*_*fan 2 javascript polymer

我希望在单击按钮时触发该函数,但不知何故,它在控制台中给出了一个错误"syntaxerror:function statement require a name".我错过了什么?

<link href="assets/polymer/paper-button/paper-button.html" rel="import">

<polymer-element name="test-button" attributes="">
  <template>
    <style>
    paper-button[default] {
      color: #4285f4;
    }
    </style>
    <paper-button label="Accept" onclick="{{ saveButton }}" default></paper-button>


    <div id="label"><content></content></div>

  </template>
  <script>
    Polymer('test-button', {
      saveButton: function() {
        alert('button clicked');
      }
    });   


  </script>
</polymer-element>
Run Code Online (Sandbox Code Playgroud)

缩短我的问题:我遗漏了我的主文件的代码,我导入元素并显示它<test-button></test-button>.谢谢你的帮助.

ebi*_*del 5

更改onclickon-click.这是使用Polymer的声明性事件处理程序.并从polymar 1中删除{{}}.