0
点赞
收藏
分享

微信扫一扫

chrome浏览器打开base64图片

笙烛 2022-01-04 阅读 122

base64图片以data:开头的一个大字符串,如图:
base64图片

页面显示base64图片

如果想要在页面显示base64图片,在img标签中使用src属性即可。

<img src={info.avatar || require('../../../../assets/images/logo.png').default} style={{ width: 56, height: 56, borderRadius: '50%' }} />

浏览器点击打开预览base64图片

如果想要在浏览器点击打开预览base64图片,使用如下的代码即可。

const img = new window.Image();
img.src = info.attachment;
const newWin = window.open('');
newWin.document.write(img.outerHTML);
newWin.document.title = info.fileName || '在职证明'
newWin.document.close();
举报

相关推荐

0 条评论