【问题标题】:Ionic PDFJS Cannot match any routes. URL Segment: 'lib/ui/index.html'Ionic PDFJS 无法匹配任何路由。 URL 段:'lib/ui/index.html'
【发布时间】:2021-07-05 21:24:39
【问题描述】:

我正在尝试使用该插件在我的 ionic 5 应用程序中打开一个 pdf npm i @ pdftron / pdfjs-express --save 但 ionic 向我显示错误无法匹配任何路线。 URL 段:'lib/ui/index.html' 请问如何纠正这个错误? 我的代码:

app.component.html

<div class="page">
      <div class="header">Angular sample</div>
       <div #viewer class="viewer"></div>
  </div>

app.component.ts

 import { Component, ViewChild, OnInit, ElementRef, AfterViewInit } from '@angular/core';
 import WebViewer from '@pdftron/pdfjs-express';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
 export class AppComponent implements OnInit, AfterViewInit {
 @ViewChild('viewer', { static: false }) viewer: ElementRef;
  wvInstance: any;

  ngAfterViewInit(): void {

  WebViewer({
  path: '../lib',
  initialDoc: '../files/webviewer-demo-annotated.pdf'
}, this.viewer.nativeElement).then(instance => {
  this.wvInstance = instance;
})
}

ngOnInit() {

}

}

【问题讨论】:

    标签: pdf ionic-framework pdfjs pdftron


    【解决方案1】:

    您在这里https://github.com/PDFTron?q=angular 使用过我们的任何角度样本吗?你可以克隆其中一个示例,看看它是如何实现的

    【讨论】:

    • 通过在 github 上克隆您的项目,一切正常。尝试在 ionic 5 项目中实现此功能时出现错误。最后我通过将 PDFTron 的 lib 文件夹移动到 ionic 的 assets 文件夹中解决了这个问题
    • 您能够找到问题听起来很棒。如果发生其他任何事情,请告诉我们!
    • 是否可以将文件存储在手机内存中并用PDFTron显示?
    猜你喜欢
    • 2020-04-24
    • 2018-09-14
    • 2019-06-16
    • 1970-01-01
    • 2017-11-13
    • 1970-01-01
    • 2017-09-25
    • 2020-04-14
    • 2019-05-11
    相关资源
    最近更新 更多