【问题标题】:Importing PDFJS breaks TS application导入 PDFJS 会破坏 TS 应用程序
【发布时间】:2017-10-09 20:38:08
【问题描述】:

所以我正在创建一个 Angular 2 - typescript 应用程序,并且我希望能够使用 Mozilla 的 PDFJS 库来探索 PDF。我已经像这样安装了依赖项:

npm install pdfjs-dist @types/pdfjs-dist --save

然后在我的 app.modules.ts 我尝试像这样导入它:

import { PDFJS } from "pdfjs-dist";

我在尝试运行tsc 时遇到以下错误,我得到以下输出:

src-ng/csm/app/app.module.ts(27,10): error TS2305: Module '"pdfjs-dist"' has no exported member 'PDFJS'.

我很茫然,因为 pdfjs-dist 的输入似乎是有序的。还有什么我应该包括的吗?

【问题讨论】:

    标签: angular typescript pdf.js


    【解决方案1】:

    你必须像这样导入它:

    import * as PDFJS from "pdfjs-dist";
    
    // or individual members
    
    import { getDocument } from "pdfjs-dist";
    

    This is due to the way TypeScript handles interop between the old module specs (CommonJS, UMD, AMD) and ES6 modules.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      相关资源
      最近更新 更多