如果我有以下情况:
var ScatterQuadrant = function ScatterQuadrant( id, _width, _height, methods )
{
this.id = id;
this.canvas = document.getElementById( id );
this.canvas.width = _width;
this.canvas.height = _height;
this.ctx = this.canvas.getContext( "2d" );
methods();
}
function Init()
{
var scatterQuad = new ScatterQuadrant(
"Frame", 800, 600, function()
{
this.ctx.fillStyle = "#FF0000"; // this.ctx isn't going to work, but what will?
this.ctx.fillRect( 0, 0, 150, 75 );
}
);
}
你会注意到我已经将一个函数推送到我的 ScatterQuadrant 函数中,我现在想要访问调用函数中的参数 ctx。我将如何去做(见我在代码中的评论)