【问题标题】:What is the purpose of aura:set in the example? [closed]示例中 aura:set 的目的是什么? [关闭]
【发布时间】:2021-01-25 07:27:26
【问题描述】:

<aura:iteration items="{!v.contactlist}" var="con">
       <div class="slds-col slds-size_1-of-3 slds-p-around_small">
         <lightning:card title="{!con.LastName}" footer="{!con.Email}" iconName="standard:contact">
           <aura:set attribute="actions">
            <lightning:button name="{!con.Id}" label="view details" variant="brand" onclick="{!c.doredirect}"></lightning:button>
           </aura:set>
         <p class="slds-p-horizontal_small">
         {!con.FirstName}  {!con.LastName}
         </p>
         <br/>
        </lightning:card>
      </div>
     </aura:iteration>

既然lightning:button已经有了onClick来触发控制器功能,那我们为什么需要 ?

请帮忙!

【问题讨论】:

    标签: salesforce salesforce-lightning force.com sfdc


    【解决方案1】:

    “设置”不是用来修改按钮的。它为您提供了一种将东西注入闪电:卡上正确位置的方法。这样,您的按钮将显示与系统中的其他卡片一致。否则你必须把按钮放在卡片主体的某个地方?或者手动重新创建整个样式(您可以使用 LDS,但如果将来样式发生变化怎么办)?

    https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_facets.htm 您可以使用相同的技巧来构建自己的可重用组件,只需注入少量更改。 LWC 使用类似的东西,但它被称为“槽”而不是“刻面”。

    【讨论】:

    • 感谢您的回复 :) 那么,是为了造型吗?
    • 将您的自定义功能放在他们在库中计划的正确占位符中。就像developer.salesforce.com/docs/component-library/bundle/… 中的第 2 和第 4 个示例一样 - 如果您需要“标题”来进行样式设置,而不仅仅是文本 - 您将如何传递它?你不能在title="&lt;b&gt;test&lt;/b&gt;" 里面写html,不会编译。或者,如果您想要页脚中的链接,您将如何做。注入他们提供的方面或从头开始制作整个组件
    猜你喜欢
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多