在阅读了 StackOverFlow 和其他网站(包括 Ionic 文档)中的所有相关帖子后,我无法使其正常工作。我试图复制相同的内容,所以目前我有:
在app.module.ts
import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
和
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
PhotoViewer
],
bootstrap: [AppComponent]
})
export class AppModule {}
在home.page.ts
import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
export class HomePage {
constructor(private photoViewer: PhotoViewer) { }
openImage() {
this.photoViewer.show(''../assets/baluarte.jpg');
}
}
在 home.page.ts
<ion-content padding>
<img src="../assets/baluarte.jpg" (click)="openImage()"/>
<ion-button (click)="openImage()">View</ion-button>
</ion-content>
我想要实现的是显示图片,当我单击时,Ionic全屏提及您的图像,并能够平移、缩放和共享图像。但是我同时尝试使用具有相同功能的按钮,以确保错误不在图像中。
也在里面
this.photoViewer.show(''../assets/baluarte.jpg');
我也在尝试使用 url,因为我不确定它是否可以与本地文件一起使用,但它也无法使用
this.photoViewer.show('https://images.app.goo.gl/cW8jBeX33H9GKAon9.jpg')
我的最终目标是使用本地文件。
PS:我当然安装了
ionic cordova plugin add com-sarriaroman-photoviewer
npm install @ionic-native/photo-viewer
谢谢你的支持