关于这里已经提出的问题
但这个问题一直没有得到回答。
我正在尝试在铁形式上添加EventListener,例如:
我的 HTML 导入:
<link rel="import" href="/bower_components/polymer/polymer.html">
<link rel="import" href="/bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="/bower_components/iron-form/iron-form.html">
<link rel="import" href="/bower_components/paper-input/paper-input.html">
<link rel="import" href="/bower_components/paper-button/paper-button.html">
<link rel="import" href="/bower_components/paper-spinner/paper-spinner.html">
表格:
<form is="iron-form" method="get" action="/" id="eventsDemo">
<paper-input name="name" label="Name" required auto-validate></paper-input>
<paper-input name="password" label="Password" type="password" required auto-validate></paper-input>
<paper-checkbox name="read" required>You must check this box</paper-checkbox>
<br>
<paper-button raised onclick="_delayedSubmit(event)" disabled id="eventsDemoSubmit">
<paper-spinner id="spinner" hidden></paper-spinner>
Submit
</paper-button>
<paper-button raised onclick="_reset(event)">Reset</paper-button>
<div class="output"></div>
</form>
和听众:
document.getElementById('eventsDemo').addEventListener('iron-form-submit', function (event) {
});
但这也让我犯了错误-
未捕获的类型错误:无法读取 null 的属性“addEventListener”
我已经尝试了一些有关 window.onload 或 WebComponentsReady 的建议。没有任何帮助。