gpt4 book ai didi

javascript - 如果图像不可用,则显示文本

转载 作者:行者123 更新时间:2023-12-02 23:12:29 25 4
gpt4 key购买 nike

我正在编写一个自定义 SharePoint Item_XX.html 模板,该模板从我的 SharePoint 自定义列表中输入数据。但我不确定如何“分解”脚本。如何使用 if-else 语句来输出显示 html?

你会看到我想说:如果有LogoSrc数据,则将数据添加到图像src中。否则显示文本(标题字段中的 dtaa)

<script> if (!LogoSrc==null){ </script>
<img src="_#= $htmlEncode(LogoSrc) =#_" />
<script> } else { </script>
<p style="font-size: 13pt; font-family: 'Malgun Gothic', Arial, sans-serif; color: #000000; font-weight: 700;">_#= Title =#_</p>
<script> } </script>

最佳答案

SharePoint Item_XX.html 文件需要特定的脚本语法。解决方案是:

<!--#_ if(LogoSrc){ _#-->
<img src="_#= $htmlEncode(LogoSrc) =#_" />
<!--#_ } _#-->
<!--#_ if(LogoSrc.isEmpty){ _#-->
<p style="font-size: 13pt; font-family: 'Malgun Gothic', Arial, sans-serif; color: #000000; font-weight: 700; text-transform: uppercase;">_#= Title =#_</p>
<!--#_ } _#-->

关于javascript - 如果图像不可用,则显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57283621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com