认识Aura Component中的.js-meta.xml文件

问题

自定义了一个Aura Component,如何限制只对Account Lightning Page可见?

探索

了解到Aura Component中有2个地方可以限制组建的可见性:
#1. 通过在.cmp文件中指定implements粗粒度限制;

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global">

#2. 通过配置.js-meta.xml文件细粒度限制;

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>56.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>AccountWrapper</masterLabel>
    <description>This component is only applicable for Account record.</description>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <objects>
                <object>Account</object>
            </objects>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

验证

通过Lightning Builder在Contact记录上依然可以看到该组件,显然探索步骤中的#1,2不成功。
因此通过ChatGPT得到如下答案:
在这里插入图片描述

结论

并不能通过探索#1,2中的步骤达到目的,需要在js中check sobjectType是否符合要求。
下图就是项目中通过Js check限制自定义组件AccountPeopleWrapper仅能被Account, Contact, Lead使用的最终使用的方案:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值