[英]Import image from './image.jpeg' results Failed to load module script The server responded with a non-JavaScript MIME type of "image/jpegerror
I was trying to import image using: 我正在尝试使用以下方式导入图像:
import image from 'image.jpeg';
the following error pops out. 弹出以下错误。
Failed to load module script: The server responded with a non-JavaScript MIME type of "image/jpeg".
无法加载模块脚本:服务器以非JavaScript MIME类型“ image / jpeg”响应。 Strict MIME type checking is enforced for module scripts per HTML spec.
根据HTML规范对模块脚本强制执行严格的MIME类型检查。
in my index.html
, I imported my main script file as: 在
index.html
,我将主脚本文件导入为:
<script src="index.js" type="module"></script>
then in the index.js
: 然后在
index.js
:
import image from 'image.jpeg';
When I run it using Chrome, it results in the above-mentioned error. 当我使用Chrome运行它时,会导致上述错误。 Any help?
有什么帮助吗?
JavaScript running in a web browser can only import JavaScript modules. 在网络浏览器中运行的JavaScript 只能导入JavaScript模块。
There are tools (such as WebPack) which can import images, but you aren't using one of them. 有一些工具(例如WebPack)可以导入图像,但是您没有使用其中之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.