【问题标题】:GlobalWorkerOptions of undefined for a React-Typescipt-Electron appReact-Typescript-Electron 应用程序未定义的 GlobalWorkerOptions
【发布时间】:2021-04-05 07:47:48
【问题描述】:

我正在尝试将 pdfjs-dist 的 example 用于 Typescript-React-Electron 应用程序。

import pdfjsLib from 'pdfjs-dist';

pdfjsLib.GlobalWorkerOptions.workerSrc = 'src/node_modules/pdfjs-
dist/build/pdf.worker.js';

我收到GlobalWorkerOptions of undefined

根据我发现的herepackage.json 我已经放了:

"source": "src/app/components/pdfHandling/entry/entry.js",

src/app/components/pdfHandling/entry/entry.js:

import * as pdfjs from 'pdfjs-dist';

pdfjs.GlobalWorkerOptions.workerSrc = 'pdf.worker.js';

export {
 pdfjs,
};

我在 Mozilla 的 GitHub 上发布了同样的问题。这是我收到的答案:

我们存储库中的独立示例工作,所以这一定是一些 与 React/Electron 的集成问题,我们无法提供 帮助,因为我们不熟悉他们。我建议问 在 StackOverflow 或其他特定于 React/Electron 的论坛上。

关于如何使pdfjs.GlobalWorkerOptions 工作的任何想法?

【问题讨论】:

    标签: reactjs typescript pdfjs pdfjs-dist


    【解决方案1】:

    问题是愚蠢而微妙的......

    替换就够了

    import * as pdfjs from 'pdfjs-dist';
    

    var pdfjsLib = require("pdfjs-dist");

    让问题消失....

    【讨论】:

      猜你喜欢
      • 2021-07-14
      • 2021-03-23
      • 2022-07-11
      • 2021-01-14
      • 2019-12-22
      • 2021-05-23
      • 2021-06-11
      • 1970-01-01
      • 2020-07-25
      相关资源
      最近更新 更多