当我尝试从类方法中运行ctx.fillRect()时,传递类对象属性时我无法获得定义。
``javascript
export default classs Reel{
constructor(gameWidth,gameHeight){
this.width = 50;
this.height = 50;
this.position = {
x: gameWIdth / 2 - this.width / 2;
y: gameHeight / 2 - this.height / 2;
}
}
draw(ctx){
ctx.fillRect(this.position.x, this.position.y, this.width, this.height);
}
}
``
它应该在画布上绘制一个矩形。