【发布时间】:2022-01-06 04:50:26
【问题描述】:
<img [src]="item.imgUrl" (error)="pictNotLoading($event)" alt="" />
pictNotLoading(event) {
event.target.src = '/assets/dynamic_images/medvibe_partner.png';
}
上述条件将替换损坏的图像。在我的产品列表页面中,我决定为每个产品项动态设置background-image(就像悬停效果一样)。
<span class="product_thumbnail_hover" style="background-image:url('{{item.imgUrl}}');"></span>
但不知何故,我从 api 调用中得到了一堆损坏的图像 URL。 所以,我的问题是如何替换样式背景图像中给出的损坏的图像 url
【问题讨论】:
标签: javascript html angular typescript