javascript - HTML SVG - load base64 string data to href of or any workaround
问题描述
I am trying to create an SVG orgchart and the get api returns json with each item (employee) having a property that is a base64 string representing an image
I want to load the base64 similar to non-svg <img> element with src="data:image/png;base64," but it doesn't seem to work with the svg element <image>
I also tried using <foreignObject> then appending <img> inside but it also does not work for base64, it only works when you have a url of the image.
I verified that the base64 string is good since when you right click the src and opened it in new tab, it actually loads the image in the new tab.
解决方案
对于可能的错误信息,我们深表歉意。异物内的 img 标签确实允许使用 data:image 格式的 base64 图像,但被我网站上的内容安全策略阻止。
推荐阅读
- arrays - 使用 VB.Net 读取/排序文件
- android - 如何从 dart/flutter 将 int/integer 值作为 json 发布
- android - react-native react-nagivation-drawer 在应用启动时默认保持打开状态
- python - 如何将参数传递给 Python 中 BaseHTTPRequestHandler 类的 GET-handler 方法
- azure - 来自 Azure 应用服务的 ioredis ETIMEDOUT,但在本地工作正常,IP 已添加到防火墙
- r - 如何在 R for 循环中用 plotly 绘制多个 y 轴
- grid - Julia 1.1 创建网格(网格中的点数组)
- ios - SwiftUI 中 VStack 的领先优势
- macos - .NET Core (OS X) - 如何添加自签名证书,绑定到 Kestrel 以获取本地主机的替代名称?
- c# - C#查找数字的位数