因为 这行代码引入有问题,vite不支持文件里的写法 vite不支持这个文件内容的写法 会报错 PDF.GlobalWorkerOptions.workerSrc = "/file/public/pdfjs-dist-res/pdf.worker.min.js"; 改成引用pdf.worker.js PDF.GlobalWorkerOptions.workerSrc= "/file/public/pdfjs-dist-res/pdf.worker.js";...
node_modules/pdfjs-dist/build/pdf.mjs:17349:53:17349│/***/__webpack_exports__ = globalThis.pdfjsLib =await(globalThis.pdfjsLibPromise = __webpack_exports__); 原因:vite 不支持顶级的 async/await 语法,需要安装插件做兼容 解决方案: vite.config.ts 安装并引入 topLevelAwait npm install vite-...
起因:公司新项目,使用Vue3 + Ts + Vite开发,老项目(Vue2 )中写过一个业务组件用到了pdfjs-dist,新项目中直接拿来用。然后惨案就发生了。。。 经过: 最开始迁过来的时候,各种报错,然后就参考这位大佬的教程→Vue3+Vite+Ts使用pdfjs-dist。参考过后,将pdfjs-dist版本固定到了2.11.338。 写法上面和大佬的写...
import * as PDF from "pdfjs-dist"; import entry from "pdfjs-dist/build/pdf.worker.entry"; // 引入时会报红线错误,不影响运行, 或在index.d.ts中声明declare import { useHooks } from "lh-hooks"; // onMounted const data = reactive<any>({ pdfPath: "/static/test.pdf", //本地PDF文件...
参考博客: https://www.52pojie.cn/thread-1391808-1-1.html 找到node-modules>pdfjs-dist>es5文件夹和node-modules>pdfjs-dist里面的cmaps文件夹整个复制到 plugins>pdf(新建pdf文件夹,把那三个小文件夹复制到这里,一个都不能少!!!)第一:印章不显示:第二: 查看一下是不是某些文件是不...
Describe the bug Terminal error: Use of eval in "node_modules/pdfjs-dist/build/pdf.js" is strongly discouraged as it poses security risks and may cause issues with minification I opened a ticket here on the pdf.js repo: mozilla/pdf.js#16...
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.解决⽅案:上述问题的原因在于:项⽬build后没有找到正确的静态资源路径,解决如下 // vite.config.js⽬录下,修改内容如下:export ...
When I try to use the newreact-pdfVite entry, it causes an error which prevents the Vite server from responding whatsoever (✘ [ERROR] Could not read from file: /myrepo/node_modules/pdfjs-dist/build/pdf.worker.js?url). Perhaps this is related to which package manager is used, but ...
当我对 dist 文件使用纱线构建命令时,我遇到了这样的错误,但我解决了它。我的主要问题是,我使用了导致此错误的 jspdf 和 jspdf-autotable 库,当我删除它们时,问题就消失了。为什么这些库存在时会报错?我需要将其添加到配置文件中吗? 我可以使用哪个 React 库来下载 pdf? Vite.config.js: import fs from "...
// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()]})可以看出,vite 官⽅已经做了⽐较完善的封装,相较于之前版本,开发体验提升了很多。按照指⽰安装完依赖,启动应⽤以后,速度确实很快。现在我们来做⼀些基本改造。我通常使⽤ less 来写样式,vite 已经做了很好的...