【问题标题】:Referance a static resource via aura:attribute在 aura:attribute 中引用静态资源
【发布时间】:2021-06-18 15:14:03
【问题描述】:

我创建了一个新组件,我希望能够通过 aura:attribute 从静态资源和自定义标签传递图像。这是我尝试过的,但它不起作用。如何使图像/文本显示?

<aura:attribute name="profileImage" type="string" default="Standard_Profile" />
<aura:attribute name="categoryName" type="string" default="Standard_Name" />

<img src="{!$Resource + !v.profileImage}" alt="profile pic"/>
<h3>{!$Label.'categoryName'}</h3>

我是 Salesforce 的新手。

【问题讨论】:

    标签: salesforce visualforce salesforce-lightning lwc aura-framework


    【解决方案1】:

    将自定义标签和静态资源中的值映射为属性中的默认值并在代码中使用

    <aura:component implements="flexipage:AvailableForAllPageTypes">
        <aura:attribute name="profileImage" type="string" default="{!$Resource.profileImage}" />
        <aura:attribute name="categoryName" type="string" default="{!$Label.c.categoryName}" />
        
        <!-- Stand-alone static resources image file-->
        <img src="{!v.profileImage}"/>
        
        <!-- custom label -->
        <div>
            {!v.categoryName}
        </div>
    </aura:component>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 2016-08-14
      • 2019-03-15
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      相关资源
      最近更新 更多