0
如何將綁定到onclick監聽器的動態創建對象的方法?在類方法中綁定帶有對象參數的onclick listner
class PanelWindow {
constructor(windowMenager) {
this.windowMenager = windowMenager;
this.makeDomElements();
this.setId(windowMenager);
}
setId(windowMenager) {
this.id = windowMenager.getId(this);
console.log(this.id);
}
createDomElements() {
var pn_header_close = document.createElement("div");
pn_header_close.onclick = this.closeWindow;
}
closeWindow() {
this.window.style.display = "none";
}
}
我想綁定到pn_header_close.onclick
這一點: this.closeWindow
或WindowActions.closeWindow(this.id, this.windowMenager)