怎么了?请告诉我 我试图从按钮运行-它不起作用。也许没有连接?但日志中没有任何内容
import '@polymer/paper-dialog/paper-dialog.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
class BuildingForm extends PolymerElement {
static get template() {
return html`
<paper-dialog id="dialog" with-backdrop="">
<h2>header</h2>
<div>Dialog body</div>
</paper-dialog>
`;
}
ready(){
window.addEventListener('openBuildingForm', e => {
this.openDialog();
});
}
static get properties() {
return {
BuildingFormHeader: String,
}
}
openDialog(){
this.$.dialog.toggle();
}
}
customElements.define('building-form', BuildingForm);
答案 0 :(得分:0)
您在super.ready()
函数中缺少ready()
调用。这是必需的,因为您要扩展PolymerElement
。
ready() {
super.ready();
/* ..and your code.. */
}
此处有更多信息:https://polymer-library.polymer-project.org/3.0/docs/devguide/custom-elements