[英]Capture X close button event in lightning quick action
你見過光環組件生命周期,尤其是圍繞(重新)渲染組件的東西嗎? 您可以附加“取消渲染”調用所需的內容。
把它放在myComponent/myComponentRenderer.js
中試試?
({
unrender: function () {
this.superUnrender();
alert('You\'re closing me, I thought we were friends');
}
})
或者看看處理aura:valueDestroy
。 我的意思是渲染器應該嘗試清理一些自定義 DOM 的東西,也許是免費的 memory,不應該運行業務邏輯。 如果有更合適的系統事件- 也許玩那個?
您是否嘗試過創建自定義事件來處理此問題?
參考:Lightning Aura 組件開發人員指南:創建自定義組件事件
使用 a.evt 資源中的<aura:event>
標記創建自定義組件事件。 事件可以包含可以在事件觸發之前設置並在事件處理時讀取的屬性。 在<aura:event>
標記中為組件事件使用type="COMPONENT"
。 例如,這個 c:compEvent 組件事件有一個名為message
的屬性。
1. <!--c:compEvent-->
2. <aura:event type="COMPONENT">
3. <!-- Add aura:attribute tags to define event shape.
4. One sample attribute here. -->
5. <aura:attribute name="message" type="String"/>
6. </aura:event>
7.
觸發事件的組件可以設置事件的數據。 要設置屬性值,請調用event.setParam()
或event.setParams()
。 事件中設置的參數名稱必須與事件中<aura:attribute>
的name
屬性匹配。 例如,如果您觸發c:compEvent
,您可以使用:
1.
2. event.setParam("message", "event message here");
3.
處理事件的組件可以檢索事件數據。 要檢索此事件中的屬性值,請在處理程序的客戶端 controller 中調用event.getParam("message")
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.