图像不显示在 Ionic 的 img src 中?
Image not displaying in img src in Ionic?
我可以点击 phone 中的照片,但我的页面上没有显示图像。
我已经安装了官方离子框架文档的插件:
$ ionic cordova plugin add cordova-plugin-camera
$ npm install --save @ionic-native/camera
这是我的代码:
getPic()
{
const options: CameraOptions = {
quality: 70,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
this.myPhoto = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
});
}
我已经在我的 class 中声明了 myPhoto:any;
。
这是我展示图片的地方:
<ion-content no-bounce padding>
<button ion-button (click)="getPic()">Take A Picture</button>
<p align="center"><img src="{{ myPhoto }}"></p>
</ion-content>
我不知道我哪里做错了。请帮我。谢谢!
private OpenCamera(): void{
const options: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation: true,
sourceType: this.camera.PictureSourceType.CAMERA,
saveToPhotoAlbum: true
}
this.camera.getPicture(options).then((imageData) => {
this.AddIssueObj.file.push(s);
this.uploadcount=this.AddIssueObj.file.length;
}, (err) => {
// Handle error
});
}
对于 HTML:
<ion-scroll scrollX="true" class="m-slider__scroll" scroll-avatar>
<span *ngFor="let v of photoList">
<img src="{{v}}" alt="slider image1" class="m-slider__img" />
</span>
</ion-scroll>
我可以点击 phone 中的照片,但我的页面上没有显示图像。 我已经安装了官方离子框架文档的插件:
$ ionic cordova plugin add cordova-plugin-camera
$ npm install --save @ionic-native/camera
这是我的代码:
getPic()
{
const options: CameraOptions = {
quality: 70,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
this.myPhoto = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
});
}
我已经在我的 class 中声明了 myPhoto:any;
。
这是我展示图片的地方:
<ion-content no-bounce padding>
<button ion-button (click)="getPic()">Take A Picture</button>
<p align="center"><img src="{{ myPhoto }}"></p>
</ion-content>
我不知道我哪里做错了。请帮我。谢谢!
private OpenCamera(): void{
const options: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation: true,
sourceType: this.camera.PictureSourceType.CAMERA,
saveToPhotoAlbum: true
}
this.camera.getPicture(options).then((imageData) => {
this.AddIssueObj.file.push(s);
this.uploadcount=this.AddIssueObj.file.length;
}, (err) => {
// Handle error
});
}
对于 HTML:
<ion-scroll scrollX="true" class="m-slider__scroll" scroll-avatar>
<span *ngFor="let v of photoList">
<img src="{{v}}" alt="slider image1" class="m-slider__img" />
</span>
</ion-scroll>