http://localhost:63342/untitled1exercise.1html/exercise1.html?_ijt=kk8leu22fhfgiu9fi47k34bc04
<!doctype html>
<html>
<head>
</title>Hello world I'm Nour Belhassen and I am in the process of making a game<title/>
</head>
<body>
</h1>Hello world I'm Nour Belhassen and I am in the process of making a game <h1/>
<canvas id="asteroids" width="400" height="400"></canvas>
<script>
var canvars = document.getElementById("asteroids")
var context = canvas.getContext("2d")
context.strokeStyle = 'dimegrey';
context.lineWidth = 5;
context.rect(75,75,250,250);
context.stroke();
// this is a comment, it has no effect!!!
</script>
</body>
</html>
为什么不尝试按键盘上的F5来重新加载页面?
在Windows上,您也可以尝试CTRLr。在MacOS上,它是CMDr。
您有一个打字错误。
// canvars
var canvars = document.getElementById("asteroids")
// canvas without 'r'
var context = canvas.getContext("2d")
这就是你的脚本失败的原因
您可以查看JS中的DOM内容加载事件。