我得到了一個菜單項是這樣的:如何訪問EventListener之外的方法? (SAPUI5)
new sap.ui.unified.MenuItem({
text: "ID",
submenu: new sap.ui.unified.Menu({
items: [this.oIdMenuButton = new sap.ui.unified.MenuItem({
text: "IDs anzeigen/ausblenden",
icon: "resources/images/check.png",
select: this._onShowHideIdRequest
})]
})
})
而且像這樣的事件監聽:
_onShowHideIdRequest: function (oControlEvent) {
}
此代碼是一個組件內。現在發生的問題是:我無法以自己的身份訪問組件。因爲當我打電話給this.
時,我訪問了觸發事件的MenuItem。我如何訪問此EventListener方法之外的方法?我知道有sap.ui.getCore().byId(id)
但通常我不知道我的組件的ID。而且我也無法存儲id,因爲我無法訪問EventHandler中的id。
我不不知道,你這是什麼意思。當我在活動中'記錄'這個對象時,就和之前一樣,MenuItem被記錄下來... – Chris
對不起,我誤解了你的問題讓我修改我的答案 – Dopedev
非常感謝!這工作正常:) – Chris