HTML img的为空的问题

https://img.mukewang.com/5c9990d5000154b808000500.jpg

请大佬看过来 我想问的是 可以设置 img为空的时候 那个默认的破损图片的样式吗?

慕仙森
浏览 981回答 4
4回答

翻翻过去那场雪

可以 img 有onerror事件vue这么写<img src="a.gif" onerror='this.src="default.gif" />$('img').error(function(){&nbsp; &nbsp; $(this).attr('src',"default.gif");})

茅侃侃

非得用img标签的话 那就 onerror事件 在加载图像的过程中如果发生了错误,就会触发onerror事件。可以使用一张透明的图片来显示 然后你的背景可以覆盖你为什么不考虑别的标签 都可以使用background

幕布斯6054654

<img&nbsp;src=""&nbsp;alt=""&nbsp;style="height:&nbsp;100px;width:&nbsp;100px;&nbsp;display:&nbsp;inline-block;">找到答案了 谢谢
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript