我正在尝试使用像<img src="{!$Resource.DealRegChannelRedDot}"/>
这样的设计属性在社区中使用静态资源中的图像
但它不是working.it显示空白,就像路径不正确一样
<!-- Component -->
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
<aura:attribute name="showBannerImage" type="boolean" default="" access="global"/>
<aura:attribute name="bannerImage" type="String" default="" access="global" />
<div class="container">
<aura:if isTrue = "{!v.showBannerImage}">
<aura:unescapedHtml value="{!v.bannerImage}"/>
</aura:if>
</div
</aura:component>
<!-- Design -->
<design:component>
<design:attribute name="showBannerImage" label="Show Banner Image" />
<design:attribute name="bannerImage" label="Banner Image" />
</design:component>
有没有办法使用静态资源来实现这一点?
发布于 2020-01-28 10:52:35
如果您已经在静态资源中上传了图片。setup>static资源,然后您可以像<img src="{!'/sfsites/c/resource/'+YOUR_STATIC_RESOURCE_NAME}"/>
一样访问图像
当您尝试使用Design property
访问图像时,您可以使用以下Lightning代码:
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
<aura:attribute name="showBannerImage" type="boolean" default="" access="global"/>
<aura:attribute name="bannerImage" type="String" default="" access="global" />
<div class="container">
<aura:if isTrue = "{!v.showBannerImage}">
<img src="{!'/sfsites/c/resource/'+v.bannerImage}" style="width: 100%;" />
</aura:if>
</div
</aura:component>
你的Lightning设计看起来也是一样的
<design:component>
<design:attribute name="showBannerImage" label="Show Banner Image" />
<design:attribute name="bannerImage" label="Banner Image" />
</design:component>
现在,您只需在showBannerImage
属性中调用静态资源名称。例如,如果您的静态资源名称是imageResource
,那么您只需在community lightning page attribute.
中调用此名称
附注:如果我的答案能帮助你解决问题,请将其标记为最佳答案。它将帮助其他人找到最佳答案。
https://stackoverflow.com/questions/59897345
复制相似问题