net::ERR_中止404(未找到)Javascript
我是javascript新手,但由于某种原因,我有这个错误 GET net::ERR_中止404(未找到) 我的代码如下所示 index.htmlnet::ERR_中止404(未找到)Javascript,javascript,html,import,Javascript,Html,Import,我是javascript新手,但由于某种原因,我有这个错误 GET net::ERR_中止404(未找到) 我的代码如下所示 index.html <html> <head> <title >Game</title> <meta charset="UTF-8" /> <style> #gameScreen { border: 1px soli
<html>
<head>
<title >Game</title>
<meta charset="UTF-8" />
<style>
#gameScreen {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="gameScreen" width="800" height="600"></canvas>
<script type="module" src="src/index.js"></script>
</body>
</html>
blade.js
import Paddle from "/src/paddle";
let canvas = document.getElementById("gameScreen");
let ctx = canvas.getContext('2d');
const GAME_WIDTH = 800;
const GAME_HEIGHT = 800;
let paddle = new Paddle(GAME_WIDTH, GAME_HEIGHT);
paddle.draw(ctx);
export default class Paddle {
constructor(gameWidth, gameHeight) {
this.width = 150;
this.height = 30;
this.position = {
x: gameWidth / 2 - this.width / 2,
y: gameHeight - this.height - 10
};
}
draw(ctx) {
ctx.fillRect(this.position.x, this.position.y, this.width, this.height);
}
}
我在index.js的第一行中发现了错误,我非常感谢任何帮助这是我如何解决这个问题而不是
import Paddle from "/src/paddle";
只需输入'js'作为消光
import Paddle from "/src/paddle.js";
您还可以使用“/className.js”