3
我无法获取base64数据URI,并且SVG显示为图像。Base64 SVG图像
我试过<img>
和<canvas>
,SVG都没有出现。
var url = 'data:image/svg+xml;base64,' + btoa('<svg height="100" width="100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red"/></svg>');
document.getElementById('image').src = url;
var context = document.getElementById('canvas').getContext('2d');
var image = new Image();
image.src = url;
context.drawImage(image, 0, 0);
canvas, img {
border: 1px solid black;
}
<img id="image" width="200" height="200">
<canvas id="canvas" width="200" height="200"></canvas>
测试在Chrome和Firefox浏览器。
什么不SVG显示?
优秀,并感谢'xlink'也有帮助。 – 2014-09-27 19:45:04