【发布时间】:2021-09-28 01:44:46
【问题描述】:
我想将 pdf 文件的第一页显示为图像。 据我所知,我不能用打字稿库“ng2-pdf-viewer”来做到这一点,因此需要使用javascript库“pdfjs-dist”。 我发现 this post 描述了如何使用 pdfjs 创建缩略图。
在“ng serve”中,我收到以下错误消息:
Error: ./node_modules/pdfjs-dist/build/pdf.js 2205:45
Module parse failed: Unexpected token (2205:45)
File was processed with these loaders:
* ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
* ./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
| intent: renderingIntent,
| renderInteractiveForms: renderInteractiveForms === true,
> annotationStorage: annotationStorage?.serializable || null
| });
| }
我发现this post 描述了如何通过更改角度构建器来解决这个问题。 然后我收到以下错误:
TypeError: Cannot read property 'flags' of undefined
我只能在 Angular 9 中找到有关此错误的提及。
因此我的问题:
- 真的有必要使用自定义构建器吗?
- 如何修复 Angular 11 中的“无法读取属性‘标志’”?
我正在使用以下依赖项:
"dependencies": {
"@angular/animations": "~11.2.13",
"@angular/common": "~11.2.13",
"@angular/compiler": "~11.2.13",
"@angular/core": "~11.2.13",
"@angular/forms": "~11.2.13",
"@angular/platform-browser": "~11.2.13",
"@angular/platform-browser-dynamic": "~11.2.13",
"@angular/router": "~11.2.13",
"@types/pdfjs-dist": "^2.7.4",
"pdfjs-dist": "^2.8.335",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},
【问题讨论】:
标签: javascript angular typescript angular11 pdfjs