最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - net::ERR_ABORTED 404 (Not Found) Javascript - Stack Overflow

programmeradmin3浏览0评论

I'm new to javascript but for some reason I have this Error GET http://127.0.0.1:5500/src/paddle net::ERR_ABORTED 404 (Not Found) my code looks like this index.html

<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>

index.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);

paddle.js

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);
   
   }

}

I get the error in first line of index.js I appreciate any kind of help

I'm new to javascript but for some reason I have this Error GET http://127.0.0.1:5500/src/paddle net::ERR_ABORTED 404 (Not Found) my code looks like this index.html

<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>

index.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);

paddle.js

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);
   
   }

}

I get the error in first line of index.js I appreciate any kind of help

Share Improve this question asked Jul 14, 2020 at 15:27 vanpersie22vanpersie22 731 gold badge1 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

this how I solved this problem instead of

import Paddle from "/src/paddle";

just type 'js' as extinction

import Paddle from "/src/paddle.js";
发布评论

评论列表(0)

  1. 暂无评论