简体   繁体   English

从'./image.jpeg'结果导入图像无法加载模块脚本服务器以非JavaScript MIME类型“ image / jpegerror”响应

[英]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.

相关问题 加载模块脚本失败:服务器以非 JavaScript MIME 类型“”响应。 强制执行严格的 MIME 类型检查 - Failed to load module script: The server responded with a non-JavaScript MIME type of “”. Strict MIME type checking is enforced 加载模块脚本失败:服务器以非 JavaScript、CSS MIME 类型“text/x-scss”响应 - Failed to load module script: The server responded with a non-JavaScript, CSS MIME type of “text/x-scss” Vue.js 3 - “加载模块脚本失败:服务器以非 JavaScript MIME 类型“text/html”响应 - Vue.js 3 - “Failed to load module script: The server responded with a non-JavaScript MIME type of ”text/html" Flask:加载模块脚本失败:服务器以“text/html”的非 JavaScript MIME 类型响应 - Flask: Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html” 无法加载模块脚本:服务器以“text/plain”的非 JavaScript MIME 类型响应 - Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain" 加载模块脚本失败:服务器响应非 JavaScript MIME 类型“” - Failed to load module script: The server responded with a non-JavaScript MIME type of "" 加载模块脚本失败:服务器以“text/plain”的非 JavaScript MIME 类型响应。 对模块强制执行严格的 MIME 类型检查 - 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 加载模块脚本失败:服务器以“text/plain”的非 JavaScript MIME 类型响应。 严格的 MIME 类型检查 i - Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking i 服务器以非 JavaScript MIME 类型的“应用程序/节点”响应 - The server responded with a non-JavaScript MIME type of “application/node” 服务器以“text/html”的非 JavaScript MIME 类型响应 - 节点 - The server responded with a non-JavaScript MIME type of "text/html" - Node
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM