forceCommunity:routeChange
ページの URL が変更されると、システムが forceCommunity:routeChange イベントを起動します。カスタム Lightning コンポーネントは、このシステムイベントをリスンし、分析や SEO などの目的で必要に応じて処理できます。
このサンプルコンポーネントは、システムイベントをリスンします。
1<aura:component implements="forceCommunity:availableForAllPageTypes">
2 <aura:attribute name="routeChangeCounter" default="0" type="Integer" required="false"/>
3 <aura:handler event="forceCommunity:routeChange" action="{!c.handleRouteChange}"/>
4 <h1>Route was changed: {!v.routeChangeCounter} times</h1>
5</aura:component>このクライアント側コントローラの例は、システムイベントを処理します。
1({handleRouteChange : function(component, event, helper) {
2 component.set('v.routeChangeCounter', component.get('v.routeChangeCounter') + 1);
3 }
4})