此 Javascript 代码在画布上绘制部分图像:
var img = document.getElementById('img');
var canvas = document.getElementById('can');
//canvas.width = img.width;
//canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
但是当我取消注释中间线以设置画布宽度和高度时,drawImage() 不起作用。我应该检查什么才能发现问题?