本篇参考:https://help.salesforce.com/s/articleView?id=release-notes.rn_lwc_workspaceAPI.htm&release=246&type=5

https://developer.salesforce.com/docs/component-library/bundle/lightning:workspaceAPI/documentation

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_methods_lightning_workspaceAPI.htm

背景: 针对Console App,我们可以看到官方提供的功能可以修改Tab名称,刷新Tab等功能。我们在针对实际开发时,偶尔也需要有需求操作Tab相关信息,比如修改Tab的名称。以前只能通过Aura Component进行修改,lwc并不支持。

Salesforce LWC学习(四十五) lwc支持Console App控制Tab了-LMLPHP

CustomizeTabAura.cmp

<aura:component implements="lightning:isUrlAddressable,flexipage:availableForAllPageTypes"
                access="GLOBAL">
    <lightning:workspaceAPI aura:id="workspace" />
    <aura:attribute name="result" type="String"></aura:attribute>

    <lightning:card>
        <lightning:buttonGroup>
            <lightning:button onclick="{!c.showTabInfo}" label="显示Tab信息"></lightning:button>

            <lightning:button onclick="{!c.changeTabInfo}" label="更改Tab信息"></lightning:button>

            <lightning:button onclick="{!c.addSubTabInfo}" label="打开Sub Tab"></lightning:button>
        </lightning:buttonGroup>
        <div>
            {!v.result}
        </div>
    </lightning:card>
    
</aura:component>
09-11 13:47