我已经导入了ng2-pdf-viewer并按照示例进行了设置,但是我得到了"ERROR Error: Uncaught (in promise):Error: Template parse error:“错误。
我尝试将导入文件移动到home.ts,但也不起作用。我真的需要弄清楚这件事。
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, PdfViewerModule],
providers: [
StatusBar,
SplashScreen,
PdfViewerModule,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}home.html
<ion-header>
<ion-toolbar>
<ion-title>
NG2-PDF-VIEWER
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<pdf-viewer src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>home.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
providers: [ ]
})
export class HomePage {
public pdf;
constructor() {
this.pdf = 'http://www.axmag.com/download/pdfurl-guide.pdf';
}
}这是我得到的完整错误:
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'src' since it isn't a known property of 'pdf-viewer'.
1. If 'pdf-viewer' is an Angular component and it has 'src' input, then verify that it is part of this module.
2. If 'pdf-viewer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-content>
<pdf-viewer [ERROR ->]src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
"): ng:///HomePageModule/HomePage.html@9:14
'pdf-viewer' is not a known element:
1. If 'pdf-viewer' is an Angular component, then verify that it is part of this module.
2. If 'pdf-viewer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-content>
[ERROR ->]<pdf-viewer src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
"): ng:///HomePageModule/HomePage.html@9:2
Error: Template parse errors:
Can't bind to 'src' since it isn't a known property of 'pdf-viewer'.
1. If 'pdf-viewer' is an Angular component and it has 'src' input, then verify that it is part of this module.
2. If 'pdf-viewer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-content>
<pdf-viewer [ERROR ->]src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
"): ng:///HomePageModule/HomePage.html@9:14
'pdf-viewer' is not a known element:发布于 2019-06-08 00:14:05
您需要将此模块(PDF查看器)准确导入到要使用其组件的模块中。
您可以在app.module.ts中找到它,但是需要通过使用它的模块来导入它
https://stackoverflow.com/questions/56482556
复制相似问题