每当我尝试运行它时,我都会在 chrome 中收到类型错误:代码更新
// Get the drawing canvas
canvas = $('#drawing');
context = canvas[0].getContext('2d');
function resizeCanvas() {
canvas.attr({'width' : $(window).width()});
canvas.attr({'height' : $(window).height() - 158});
var dataURL = canvas[0].toDataURL('image/png');
context.drawImage(dataURL, 0, 0);
}
$(window).resize(function() {
resizeCanvas();
}); resizeCanvas();
// Various event handlers after this.
为什么!?