我正在尝试在画布上绘制图像。该图像位于 html 文件的文件夹中。但是当我调用 drawImage() 函数时,图像不会绘制。这是我的代码,
var upcan = document.createElement("canvas");
upcan.width = "190";
upcan.height = "380";
upcan.style.cssText = 'border-radius:25px; '
var upctx = upcan.getContext('2d');
var pb = new Image();
pb.onload = function() {
upctx.drawImage(pb,0,0,100,400);
};
pb.src = "photobooth.png";
var canvasData = upcan.toDataURL("image/png");