[英]Replace image with div if image doesn't exists
how correctly reflect image if it exists & replace it with div
otherwise? 如何正确反映图像(如果存在)并用
div
替换?
// I don't know how to get `imageExists` without making cross-origin
(imageExists) ? (<img class="avatar-img" src={this.state.imageDataUrl}/>) :
(<div class="avatar-img no-avatar"><span>{shortcut}</span></div>)
Of course I can do separate XmlHttpRequest
but that's lots of unnecessary code + cross-origin. 当然,我可以单独做
XmlHttpRequest
但这有很多不必要的代码+跨域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.