我尝试将画布下载为图像,但是下载的背景透明。如何为图片设置背景颜色?
这是我尝试过的代码:
this.canvas = document.getElementById('barchart') as HTMLCanvasElement;
var download = document.getElementById("download");
let url = this.canvas.toDataURL("image/png").replace("image/png","image/octet-stream");
download.setAttribute("href", url);