Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 图像未在离子2的UI中更新。如何在中动态显示更改图像?_Ionic Framework - Fatal编程技术网

Ionic framework 图像未在离子2的UI中更新。如何在中动态显示更改图像?

Ionic framework 图像未在离子2的UI中更新。如何在中动态显示更改图像?,ionic-framework,Ionic Framework,我正在从相机拍摄照片并上传到服务器,然后从服务器返回照片的url。但上一张照片仍然存在。图像未更新。您必须在TYPESCRIPT中创建一个变量,例如: path:String = ""; 然后是拍照功能 takePicture(){ Camera.getPicture({ destinationType: Camera.DestinationType.DATA_URL, targetWidth: xxx,

我正在从相机拍摄照片并上传到服务器,然后从服务器返回照片的url。但上一张照片仍然存在。图像未更新。

您必须在TYPESCRIPT中创建一个变量,例如:

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" />