Lightning Experience の getEnclosingTabId()
囲んでいるタブの ID を返します。このメソッドは、Lightning コンソールアプリケーションでのみ機能します。
引数
なし。
サンプルコード
このコンポーネントにはボタンがあり、押すと、囲んでいるタブの ID が取得されます。
コンポーネントコード:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2 <lightning:workspaceAPI aura:id="workspace" />
3 <lightning:button label="Get Enclosing Tab Id" onclick="{! c.getEnclosingTabId }" />
4</aura:component>コントローラコード:
1({
2 getEnclosingTabId : function(component, event, helper) {
3 var workspaceAPI = component.find("workspace");
4 workspaceAPI.getEnclosingTabId().then(function(tabId) {
5 console.log(tabId);
6 })
7 .catch(function(error) {
8 console.log(error);
9 });
10 }
11})応答
このメソッドは、成功時に囲んでいるタブの tabId (タブ内の場合) または false (タブ内でない場合) に解決される Promise を返します。