gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 18:08:15 26 4
gpt4 key购买 nike

所以我正在创建一个 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.

关于angular - 导入 PDFJS 会破坏 TS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45467843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com