我希望在单击按钮时触发该函数,但不知何故,它在控制台中给出了一个错误"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>.谢谢你的帮助.