我有这段代码(sCtx是一个画布上下文,按钮处于一个紧密的绘制循环中):
function Button(src, onClick)
{
this.loaded = false;
this.image = new Image();
this.image.src = src;
this.onClick = onClick;
}
Button.prototype.draw = function()
{
if(!this.image.complete)
return;
var theImg = this.image;
console.log(theImg);
sCtx.drawImage(theImg);
}
当我运行代码(在Chrome中)时,我得到如下输出:
<img src=“img/btnStart.png”>
未捕获类型错误:类型错误
有人能告诉我我做错了什么吗?我看了很多例子,看来这应该管用。