我正在实例化一个模块,如下所示index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello Module</title>
</head>
<body>
<script type="module" src="./index.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
index.js是空的。
当我通过(Python 3.8.5)提供此服务时py -3 -m http.server,我收到 Chrome 错误:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
Run Code Online (Sandbox Code Playgroud)
我已经读过这个错误的含义。我不知道如何配置 http.server,因为迄今为止它对我来说一直是一个黑匣子。我是否已经过了 Python 默认(?)服务器有用的阶段?