Ionic framework 图像未在离子2的UI中更新。如何在中动态显示更改图像?
我正在从相机拍摄照片并上传到服务器,然后从服务器返回照片的url。但上一张照片仍然存在。图像未更新。您必须在TYPESCRIPT中创建一个变量,例如:Ionic framework 图像未在离子2的UI中更新。如何在中动态显示更改图像?,ionic-framework,Ionic Framework,我正在从相机拍摄照片并上传到服务器,然后从服务器返回照片的url。但上一张照片仍然存在。图像未更新。您必须在TYPESCRIPT中创建一个变量,例如: path:String = ""; 然后是拍照功能 takePicture(){ Camera.getPicture({ destinationType: Camera.DestinationType.DATA_URL, targetWidth: xxx,
path:String = "";
然后是拍照功能
takePicture(){
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL,
targetWidth: xxx,
targetHeight: yyy
}).then((imageData) => {
// imageData is a base64 encoded string,
this.path = "data:image/jpeg;base64," + imageData;
//create a function here to send the photo and the return will be the link
this.path = getServerLink();
}, (err) => {
console.log(err);
});
}
然后是HTML
<img src="{{path}}"/>
<!--or -->
<img [src]="path" *ngIf="path" />