我有一个 svg 图像,即 img src="image.svg"。如何使此标签在浏览器中转换为 svg 标签。我刚刚尝试使用图像标签,但浏览器将其呈现为图像标签,而不是 svg
最佳答案
而不是使用 img 使用 <embed>
或 <object>
标签并尝试 .contentDocument
或 getSVGDocument()
获取 svg 文件的内容。
查看此链接的源代码以获取实时示例 http://xn--dahlstrm-t4a.net/svg/html/get-embedded-svg-document-script.html
关于javascript - Img.svg 到 svg 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36214765/