我正在使用 ionic 6 和 angular 12,我正在浏览器上测试我的应用程序并且它工作正常,问题是当我尝试在模拟器或手机上测试它时。我在 chrome 上检查它,它给了我这些错误,并且在启动屏幕之后它给出了一个空白屏幕。
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec. runtime.js
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec. main.js
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec. polyfills.js
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec. vendor.js
这是我的 index.html 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Noz Terra</title>
<base href="./">
<meta name="color-scheme" content="light dark" />
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<link rel="icon" type="image/png" href="./assets/imgs/nozterra1.png" />
<!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head>
<body>
<app-root>
</app-root>
</body>
</html>
这是我编译时在 www 文件夹中生成的 index.html 文件(我认为这是问题的根源):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Noz Terra</title>
<base href="./">
<meta name="color-scheme" content="light dark"/>
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="msapplication-tap-highlight" content="no"/>
<link rel="icon" type="image/png" href="./assets/imgs/nozterra1.png"/>
<!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<link rel="stylesheet" href="styles.css"></head>
<body>
<app-root>
</app-root>
<script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="cordova.js" defer></script><script src="vendor.js" type="module"></script><script src="main.js" type="module"></script></body>
</html>