这里是实时站点:https://topi1.github.io/phaser-game/ 这是代码:https://github.com/Topi1/phaser-game
尝试将我的第一个移相器游戏部署到 GitHub Pages,但出现错误: 由于不允许的 MIME 类型(“text/html”),从“https://topi1.github.io/main.js”加载模块被阻止。 移相游戏 源“https://topi1.github.io/main.js”的模块加载失败。
我真的不明白我应该做什么不同的事情。任何帮助表示赞赏。
index.html 目前看起来像:
`<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Game</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser-arcade-physics.min.js"></script>
</head>
<body>
<header>
<p>Demo</p>
</header>
<main>
<canvas id="gameCanvas">
</canvas>
</main>
<footer>
Created by Topi 2024
</footer>
<script type="module" src="/main.js"></script>
</body>
</html>
`
我尝试过在index.html 中移动main.js,我尝试过src="main.js" 和src="/main.js" 的两种变体。我还尝试从模块更改脚本类型,但没有成功。
使用相对的
src
<script type="module" src="./main.js"></script>
而不是
<script type="module" src="/main.js"></script>
–
/main.js
指的是 https://topi1.github.io/main.js
(正如您所注意到的),但您的项目位于 /phaser-game/
子目录中。