美文网首页
【ng2-pdf-viewer】Cannot read prop

【ng2-pdf-viewer】Cannot read prop

作者: 匿于烟火中 | 来源:发表于2019-07-19 15:41 被阅读0次

报错场景:在boostrap modal中使用ng2-pdf-viewer预览pdf,多次打开pdf出现报错

    <ng-template #attachPreview let-modal>
        <pdf-viewer 
        #pdfPreviwer
        [src]="previewDoc.url" 
        [render-text]="false"
        [original-size]="true"
        style="display: block;width: fit-content;" 
        >
        </pdf-viewer>
    </ng-template>

解决方案:

ng2-pdf-viewer has a dependency called pdfjs-dist. You can find it in node_modules.
Open this file -> node_modules/pdfjs-dist/web/pdf_viewer.js
In pdf_viewer.js file, search for this line of code -> var elt = views[index].div; It is inside 'backtrackBeforeAllVisibleElements' function.
Change that code line to var elt = views[index-1].div; and save.

github

相关文章

网友评论

      本文标题:【ng2-pdf-viewer】Cannot read prop

      本文链接:https://www.haomeiwen.com/subject/cxngkctx.html