如果背景图像不存在,则在角度中显示另一个背景

if background image is not there, then show anothe background in Angular

本文关键字:背景 另一个 显示 图像 不存在 如果      更新时间:2023-09-26

我正在使用Angularjs

我有这个代码

<span variant="2" class="thumb" style="background-image: url(1UP-Cook/31UP-Cook-articleLarge.jpg'); width: 270px; height: 270px;"></span>

现在我想要如果我的背景 src 不存在

我想在上面显示默认图像。

任何想法,如何做到这一点

谢谢

尝试一下,将默认图像设置为背景.thumb_wrapper。

span {display:block}
<span class="thumb_wrapper" style="background-color:red">
    <span 
        class="thumb" 
        style="background-image: url('1UP-Cook/31UP-Cook-articleLarge.jpg'); width: 270px; height: 270px;"
    >
        lorem
    </span>
</span>