无法在画布中加载图像以获取编码Base64代码
代码
var html = new XMLSerializer().serializeToString(document.getElementById("d3"));
var img = document.getElementById("img") as HTMLImageElement
img.src = "data:image/svg+xml;base64," + btoa(html.toString())
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png"); --> showing SecurityError
var data = dataURL.replace("data:image/svg+xml;base64", "");
提前致谢