【发布时间】:2023-12-01 15:30:01
【问题描述】:
我是离子/角度的新手。在我的编辑个人资料页面(不同页面)中,我可以更改个人资料图片,它应该在主要个人资料页面(另一个页面)中反映相同,这两个页面是不同的。
HTML:
<ion-item lines="none">
<ion-avatar class="ion-align-self-left" id="pic" (click)="change()">
<img src="{{myphoto}}">
</ion-avatar>
</ion-item>
TS:
export class ProfilePage implements OnInit {
myphoto:any;
constructor(private camera: Camera) {
this.myphoto = '/assets/img/DP.svg';
this.statusBar.backgroundColorByHexString('#ffffff');
}
ngOnInit() {
}
take(){
this.ishide =true;
this.hide_input =false;
const options: CameraOptions = {
quality: 70,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.myphoto = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
}
get() {
this.ishide =true;
this.hide_input =false;
const options: CameraOptions = {
quality: 70,
destinationType: this.camera.DestinationType.DATA_URL,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
saveToPhotoAlbum:false
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.myphoto = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
}
}
【问题讨论】:
标签: angular ionic-framework ionic4