简体   繁体   English

未捕获的语法错误:意外标记

[英]uncaught syntax error : unexpected token

im making a pong clone with js and i am using windows.onload fucnction and it says that there is a period that isn't supposed to be there idk where they could be talking about and it says its on the windows.onload function line我正在用 js 制作 pong 克隆,我正在使用 windows.onload 功能,它说有一段时间不应该在那里他们可以谈论的地方,它说它在 windows.onload 功能行上

 <canvas id="pg" width = "800" height = "600"> <script> var c; var cc; var ballx = 50; var bally = 50; var window.onload = function(){ c = document.getElementById("pg"); cc = c.getContext("2d"); var fps = 180; setInterval(draw,1000/fps) } function draw(){ ballx += 1.5; cc.fillStyle = "black"; cc.fillRect(0,0,c.width,c.height); cc.fillStyle = "white"; cc.fillRect(ballx,bally,10,10); cc.fillRect(10,210,100,25); } </script> </canvas>

You have left an empty var declaration at line 5 of your script tag.您在脚本标记的第 5 行留下了一个空的 var 声明。 This breaks the window.onload event callback.这会中断 window.onload 事件回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM