我想将带有图像的 SVG 转换为 png。在 Firefox 和 Chrome 中,一切正常,但在 Safari 中,转换忽略了 SVG 中的图像。
我正在使用的库是 html-to-image (html2canvas 给了我相同的结果)
这是一个codepen(脸是图像) https://codepen.io/RainPara/pen/MWvqZNz
var node = document.getElementById('item');
htmlToImage.toPng(node)
.then(function (dataUrl) {
var img = new Image();
img.src = dataUrl;
document.body.appendChild(img);
})
.catch(function (error) {
console.error('oops, something went wrong!', error);
});
也许有人可以帮助我