导入PDFJS会中断TS应用程序 [英] Importing PDFJS breaks TS application

查看:83
本文介绍了导入PDFJS会中断TS应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在创建一个Angular 2-打字稿应用程序,我希望能够使用Mozilla的PDFJS库浏览PDF.我已经这样安装了依赖关系:

So I'm creating an Angular 2 - typescript application and I want to be able to explore PDFs using Mozilla's PDFJS library. I have installed the depenedencies like so:

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

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

Then in my app.modules.ts I attempt to import it like so:

import { PDFJS } from "pdfjs-dist";

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

And I'm met with the following error when trying to run tsc I get the following output:

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

我很茫然,因为看来pdfjs-dist的输入似乎井井有条.我还应该包括些其他东西吗?

I'm at a loss because it appears that the pdfjs-dist typing appears to be in order. Is there something else I should include?

推荐答案

您必须像这样导入它:

import * as PDFJS from "pdfjs-dist";

// or individual members

import { getDocument } from "pdfjs-dist";

这是由于TypeScript处理旧模块规范(CommonJS)之间的互操作的方式,UMD,AMD)和ES6模块.

这篇关于导入PDFJS会中断TS应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆