angular – 导入PDFJS会破坏TS应用程序

前端之家收集整理的这篇文章主要介绍了angular – 导入PDFJS会破坏TS应用程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我正在创建一个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打字似乎是有序的.我还应该包括其他什么吗?

解决方法

你必须像这样导入它:

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.

猜你在找的Angularjs相关文章