当将类导入到另一个javascript文件时,我遇到了一个名为Uncaught SyntaxError:Identifier'
的错误。/*paddle.js*/
export default class paddle
{
constructor(gameWidth,gameHeight)
{
this.width=150;
this.height=30;
this.postion={
x:gameWidth/2-this.width/2,
y:gameHeight-this.height-10,
}
}
draw(ctx)
{
ctx.fillRect(this.postion.x,this.postion.y,this.width,this.height);
}
/*index.js*/
import paddle from'/src/paddle';
let canvas=document.getElementById('gameScreen');
let ctx=canvas.getContext("2d");
const GAME_WIDTH=800;
const GAME_HEIGHT=600;
let paddle =new paddle(GAME_WIDTH,GAME_HEIGHT);
paddle.draw(ctx);
}
我希望看到一个画布对象(桨)