1、第一次使用画布,在定义获取画布环境就出现bug
can1 = document.getElementById("canvas1");//fishes,dust,UI,circle
ctx1 = can1.getContext();
BUG界面:
意思是,getContext() 需要参数,但现在没有。
但原先确实没有给参数,也没有报错,可能是因为版本更新问题?
改成以下带有参数的形式,
ctx1 = can1.getContext("2d");
果然浏览器就不报错了。
2、函数没带参数
fruitObj.prototype.born = function () {
var aueID = Math.floor(Math.random() * ane.num);
this.x[i] = ane.x[aueID];
this.y[i] = canHeight - ane.len[aueID];
}
报错界面
传入参数i 即可解决该问题
fruitObj.prototype.born = function (i)