跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] wails 中调用 pdf.js 显示 pdf 只能使用 cdn 上的 js 库文件,下载下来放本地编译打包之后就报错

发表于
pdfjsLib.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.mjs`;

使用这个不管是 wails dev 开发,还是 wails build 都可以正常显示 PDF 因为是公司内部 PDF 文件,有些是不连外网的,就想使用本地 js 文件 改成

pdfjsLib.GlobalWorkerOptions.workerSrc = `./pdf.worker.mjs`;

这样后,wails dev 可以工作,wails build 后报错

Error: Setting up fake worker failed: "Failed to fetch dynamically imported module: http://wails.localhost/assets/pdf.worker.mjs".
    at index.eb935618.js:265:173429

考虑是否是 wails 静态文件问题,那就自己搭建 JS 静态资源,改成

pdfjsLib.GlobalWorkerOptions.workerSrc = `http://192.168.0.8:8888/pdf.worker.mjs`;

结果还是报上面错误。无语了,难道 cdn 上的 js 和下载下来的不一样?

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.