有没有办法在页面加载后一瞬间不显示损坏的图像标签?
请参见以下示例:http://jsfiddle.net/v8DLe/196/
我已经使用了:onerror="this.style.display ='none'"
我还是希望使用img标签,而不要使用带有style={{ backgroundImage: ...}}
答案 0 :(得分:4)
尝试先将其隐藏。在onLoad上显示它们?
img {
display: none;
width:200px;
height:200px;
}
<img src="abc" alt=" " onload="this.style.display ='block'"/>
<img src="abc" alt=" " onload="this.style.display ='block'"/>
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt=" " onload="this.style.display ='block'"/>
<img src="abc" alt=" " onload="this.style.display ='block'"/>
<img src="abc" alt=" " onload="this.style.display ='block'"/>
<img src="abc" alt=" " onload="this.style.display ='block'"/>