拒绝从 '...' 执行脚本,因为其 MIME 类型 ('text/html') 不可执行,并且启用了严格的 MIME 类型检查

问题描述

我在我的带有 expressjs 服务器的 vanilla JS 应用程序中尝试使用 html2pdf 时遇到此错误。谷歌搜索了很多,但找不到解决方案。请求帮助。我的代码是:

<script src="/html2pdf.bundle.min.js" type="application/javascript"></script>

// downloading HTML as PDF
      document
        .getElementById("download-button")
        .addEventListener("click",() => {
          const doc = document.getElementById("doc-to-download");
          html2pdf(doc);
        });

//in server.js file...
app.use(express.static("public"))

//html2pdf.bundle.min.js file is in public folder.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)