2

在我angular10必须将PDF文件显示为preview. 所以为此我正在使用ngx-doc-viewer. 我的组件看起来像这样

组件.html

<ngx-doc-viewer [url]="inputFile.filePath" viewer="mammoth" 
  style="width:100%;height:60vh">
</ngx-doc-viewer>

组件.ts

const reader = new FileReader();
reader.readAsDataURL(inputFile);
reader.onload = (_event) => {
  this.inputFile.filePath = reader.result;
}

角.json

scripts : [
 "node_modules/mammoth/mammoth.browser.min.js"
]

当我上传任何.doc,.docx,.xlsx文件以便它chrome完美地加载该文件但是当我尝试使用ngx-doc-viewer它时它会出现错误chrome's console

Unsupported viewer: 'mammoth'. Supported viewers: google, office.

在此处输入图像描述

我该如何解决?

4

0 回答 0