Aura 应用程序事件已成功触发,但处理程序组件似乎无法侦听或处理它,并且它没有调用操作方法openFeed。这是处理应用程序事件的组件。
<aura:component controller="ConnectApiCallsController">
<aura:attribute name="yourfeed" type="PortalFeedWrapper[]" access="public"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:handler event="c:DraggableNavEvent" action="{!c.openFeed}" />
<aura:handler event="aura:doneRendering" action="{!c.doneRendering}" /> // not working if removing this line
<div>
<div class="feedWrapper slds-scrollable" >
<div class="tab">
<c:HorizontalDraggableNav/>
</div>
<div id="yourFeedTab" class="tabcontent">
<c:YourFeedWrapper feeds="{!v.yourfeed}"/>
</div>
<div id="discussionsByTopicsTab" class="tabcontent">
<c:DiscussionsByTopicsWrapper />
</div>
<!-- PrivateFeeds By THiru-->
<div id="privateFeedTab" class="tabcontent">
<c:PrivateFeedWrapper isUserInternal="{!v.isInternalUser}"/>
</div>
</div>
</div>
</aura:component>
当我从组件中删除 doneRendering 时,调用 openFeed 就好了,但问题是为什么 doneRendering 需要在那里才能工作?我没有在控制器上声明任何 doneRendering 方法。我做错了什么, doneRendering 需要留在那里才能正常工作?此外,这是父组件,而触发应用程序事件的组件是c:HorizontalDraggableNav,使用以下代码:
var appEvent = $A.get("e.c:DraggableNavEvent");
appEvent.setParams({ feedType: e.target.id });
appEvent.fire();
该组件如下所示:
<aura:component>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:handler name="render" value="{!this}" action="{!c.onRender}" />
<aura:attribute name="isLoginUserInternal" type="Boolean" default="false" /> <!-- PrivateFeeds By Thiru-->
<aura:registerEvent name="appEvent" type="c:DraggableNavEvent" />
<div class="grid-container">
<div class="grid-item main">
<div class="items" id="items">
<div class="item" id="yourFeed">Your feed</div>
<div class="item" id="discussionsByTopics">Discussions by topics</div>
<!-- PrivateFeeds By Thiru-->
<aura:if isTrue="{!v.isLoginUserInternal}">
<div class="item" id="privateFeed">Valmet internal</div>
</aura:if>
</div>
</div>
</div>
</aura:component>
关于这个问题的任何想法或解决方案?