【React】pdf.js 'GlobalWorkerOptions' of undefined

用的是pdf.js,引用如下

【React】pdf.js  'GlobalWorkerOptions' of undefined
pdfjsLib输出为undefined
版本 "pdfjs-dist": "^2.2.228"

回答

不好意思,自问自答
改用require

const pdfjsLib = require('pdfjs-dist');

pdfjsLib.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry');

是突然在一篇博客看到的:
https://blog.csdn.net/xss392795158/article/details/108079627

以上是 【React】pdf.js 'GlobalWorkerOptions' of undefined 的全部内容, 来源链接: utcz.com/a/76923.html

回到顶部