tttggd 2023-12-25 16:21 采纳率: 50%
浏览 7
已结题

html使用 photo-sphere-viewer 报错,求大解答

一生平安,全家幸



<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>360T22</title>
</head>
<!-- the viewer container must have a defined size -->
<div id="viewer" style="width: 100vw; height: 90vh;"></div>
<script type="module">
import { Viewer } from "./@photo-sphere-viewer/core";
import { MarkersPlugin } from "./@photo-sphere-viewer/markers-plugin";
import { GalleryPlugin } from "./@photo-sphere-viewer/gallery-plugin";
import { AutorotatePlugin } from "./@photo-sphere-viewer/autorotate-plugin";
import "./@photo-sphere-viewer/core/index.css";
import "./@photo-sphere-viewer/markers-plugin/index.css";
import "./@photo-sphere-viewer/gallery-plugin/index.css";
    const viewer = new Viewer({
        container: document.querySelector('#viewer'),
        panorama: 'image/1.jpg',
    });
    </script>
</body>
</html>

网页运行报错:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.index.css:1
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.index.css:1
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.markers-plugin/:1
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.gallery-plugin/:1
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.autorotate-plugin/:1
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.core/:1
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
依赖包在本地

img

  • 写回答

2条回答 默认 最新

  • 小孟多 2023-12-25 16:29
    关注

    这个错误提示表明在加载一些 JavaScript 模块时,服务器返回的 MIME 类型与预期的不匹配。在你的情况下,服务器返回的是text/css或text/html,而不是 JavaScript 模块的text/javascript。
    这可能是由于服务器配置问题或文件扩展名不正确导致的。确保以下几点:
    文件扩展名:确保你的模块文件具有正确的扩展名.js。
    服务器配置:如果你使用的是服务器来提供文件,确保服务器正确配置了MIME 类型。对于 JavaScript 模块,应该将其设置为text/javascript。
    文件路径:确保你指定的模块文件路径是正确的,并且指向实际的 JavaScript 文件。
    如果你确认以上几点都没有问题,但仍然遇到该错误,可能是由于某些其他配置问题或加载顺序导致的。你可以尝试使用其他的模块加载方法,例如使用 CDN 来加载你的依赖项。
    如果问题仍然存在,请提供更多的上下文和代码示例,

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月2日
  • 已采纳回答 12月25日
  • 修改了问题 12月25日
  • 创建了问题 12月25日

悬赏问题

  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥15 基于作物生长模型下,有限水资源的最大化粮食产量的资源优化模型建立
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo
  • ¥15 科来模拟ARP欺骗困惑求解
  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver