我是 JavaScript 中的 OO 新手,并试图制作这个简单的画布演示:
var c; // typeof c is the canvas element
function SolarSystem(plane, sun) {
this.plane = plane; // typeof plane is Canvas Ctxt
this.sun = sun;
this.init = function () {
draw();
}
this.render = function () {
c.height = c.height;
requestAnimationFrame(this.render);
this.draw();
}
this.draw = function () {
console.log(1);
}
}
我想要做的是,为了渲染SolarSystem
,我想调用它里面的 render() 。我不能从渲染()调用渲染(),我怎么能不进入Uncaught TypeError: Type error
控制台呢?谢谢!