尝试使用ionic cordova build android --prod --release
或使用ionic serve
或ionic cordova run android
应用程序效果很好。
错误:c:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.t.ts中键入pdfviewercomponent,是2个模块声明的一部分:c:/app/node_modules/ng2-2-2--pdf-viewer/ng2-pdf-viewer.d.t.ts和pdfmodalpagemodule中的c:/app/src/pages/document-pdf/document-pdf/document-pdf.module.ts!请考虑在c:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.t.ts中移动pdfviewercompongent,以在c:/app/nonode_modules/ng2-pdf-viewer/ng2-viewer/ng2-ng2-ng2-ng2-ng2-ng2-ng2--pdf-viewer.d.t.ts和pdfmodalpagemodule中的c:/app/src/pages/document-pdf/document-pdf.module.ts。您还可以创建一个新的ngmodule,该新ngmodule在c:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中导入pdfviewercomponent.d.t.t.-pdf-viewer/ng2-pdf-viewer.d.ts和pdfmodalpagemodule in c:/app/src/pages/document-pdf/document-pdf/document-pdf.module.ts。
我仅在 document-pdf.module.ts
中导入ng-pdf-viewer,而不是在app.module.ts
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {PdfModalPage} from "./document-pdf";
import {PdfViewerComponent} from "ng2-pdf-viewer";
@NgModule({
declarations: [PdfModalPage, PdfViewerComponent],
imports: [IonicPageModule.forChild(PdfModalPage)],
})
export class PdfModalPageModule {}
Angular&离子版本
{
"name": "Test",
"version": "0.0.1",
"description": "",
"license": "Apache-2.0",
"scripts": {
"build": "ionic-app-scripts build",
"clean": "ionic-app-scripts clean",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"i18n": "ng-xi18n"
},
"dependencies": {
"@angular/common": "4.4.6",
"@angular/compiler": "4.4.6",
"@angular/compiler-cli": "4.4.6",
"@angular/core": "4.4.6",
"@angular/forms": "4.4.6",
"@angular/http": "4.4.6",
"@angular/platform-browser": "4.4.6",
"@angular/platform-browser-dynamic": "4.4.6",
"@ionic-native/app-version": "4.5.2",
"@ionic-native/background-mode": "^4.5.3",
"@ionic-native/contacts": "4.5.2",
"@ionic-native/core": "3.14.0",
"@ionic-native/device": "4.5.2",
"@ionic-native/diagnostic": "^4.5.2",
"@ionic-native/file": "4.5.2",
"@ionic-native/file-chooser": "4.5.2",
"@ionic-native/file-path": "4.5.2",
"@ionic-native/firebase": "^4.5.3",
"@ionic-native/in-app-browser": "3.14.0",
"@ionic-native/media": "4.5.2",
"@ionic-native/media-capture": "4.5.2",
"@ionic-native/network": "^4.5.2",
"@ionic-native/onesignal": "4.5.2",
"@ionic-native/screen-orientation": "4.5.2",
"@ionic-native/sim": "4.5.2",
"@ionic-native/splash-screen": "3.14.0",
"@ionic-native/sqlite": "^4.5.2",
"@ionic-native/status-bar": "3.14.0",
"@ionic-native/unique-device-id": "4.5.2",
"@ionic-native/video-editor": "^4.5.2",
"@ionic-native/video-player": "^4.5.2",
"@ionic/pro": "^1.0.16",
"@ionic/storage": "2.0.1",
"angular2-moment": "1.7.0",
"angular2-signaturepad": "2.6.1",
"angularfire2": "^5.0.0-rc.3",
"com-badrit-base64": "^0.2.0",
"cordova-android": "^6.4.0",
"cordova-ios": "^4.5.4",
"cordova-plugin-app-version": "^0.1.9",
"cordova-plugin-background-mode": "^0.7.2",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-console": "^1.1.0",
"cordova-plugin-contacts": "^2.3.1",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-filechooser": "^1.0.1",
"cordova-plugin-filepath": "^1.2.0",
"cordova-plugin-firebase": "^0.1.25",
"cordova-plugin-inappbrowser": "^1.7.2",
"cordova-plugin-ionic": "^3.1.0",
"cordova-plugin-media": "^3.0.1",
"cordova-plugin-media-capture": "^1.4.3",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-screen-orientation": "^2.0.2",
"cordova-plugin-sim": "^1.3.3",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-statusbar": "^2.4.1",
"cordova-plugin-video-editor": "^1.1.3",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.2.0",
"cordova.plugins.diagnostic": "^3.9.2",
"es6-promise-plugin": "^4.2.2",
"firebase": "^4.9.1",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionic2-auto-complete": "1.6.2-alpha",
"ionicons": "3.0.0",
"ng2-pdf-viewer": "4.1.0",
"ng2-timeago": "1.0.7",
"onesignal-cordova-plugin": "^2.2.5",
"rxjs": "5.5.5",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"@ionic/app-scripts": "^3.1.8",
"ionic": "3.19.1",
"typescript": "2.6.2"
},
"config": {},
"cordova": {
"platforms": [
"android",
"ios"
],
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-file": {},
"cordova-plugin-filechooser": {},
"cordova-plugin-app-version": {},
"cordova-plugin-filepath": {},
"onesignal-cordova-plugin": {},
"cordova-plugin-media-capture": {},
"cordova-plugin-screen-orientation": {},
"cordova-plugin-media": {},
"cordova-plugin-contacts": {},
"cordova-plugin-sim": {},
"com-badrit-base64": {},
"cordova-plugin-network-information": {},
"cordova-plugin-video-editor": {},
"cordova-sqlite-storage": {},
"cordova.plugins.diagnostic": {},
"cordova-plugin-firebase": {},
"cordova-plugin-background-mode": {}
}
}
}
离子信息
cli packages: (C:appnode_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.4.0
Ionic Framework : ionic-angular 3.9.2
我尝试使用新的安装删除/平台/www/插件和/node_modules
您应该在document-pdf.module.ts
中导入PdfViewerModule
,并且不在其中声明PdfViewerComponent
,因为它已经在PdfViewerModule
中声明。
更新:这就是您的模块的外观:
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {PdfModalPage} from "./document-pdf";
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({
declarations: [PdfModalPage],
imports: [IonicPageModule.forChild(PdfModalPage), PdfViewerModule]
})
export class PdfModalPageModule {}