[英]How to display a base64 image in a popover
我已经使用此代码在我的网页(基于液体模板构建的 MS 动态门户)上成功显示了 base64 图像,然后将该元素附加到 div:
imageElementCaseNote.src = 'data:image/png;base64, ${Picture}';
我遇到的问题是:如何设置imageElementCaseNote
的 'data-content' 属性,我尝试了以下操作,但得到[object HTMLImageElement]
而不是图像。
imageElementCaseNote.setAttribute('data-content', 'data:image/png;base64, ${Picture}');
我需要做什么? 我认为数据需要添加为 html,但我不知道该怎么做。
所有帮助表示赞赏。
我错过了两件事,一件很明显,另一件则不太明显。
显而易见:我需要将数据包装在图像标签中:
popImage = '<img src="' + imageElementCaseNote.src + '"/>';
ImageElementCaseNote.setAttribute('data-content', popImage);
不太明显:我需要设置 data-html 属性:
imageElementCaseNote.setAttribute('data-html', 'true');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.