0

我会尝试一些解决方案,但不能存储在的base64阵列 1. HTML代码离子V2察相机拍摄的快照返回Base64和数组不存储

<ion-content padding id="ezarcontent"> 
</ion-content> 
<ion-footer> 
    <button ion-button color="danger" (click)="takePhotos()"> 
    <ion-icon name="camera"></ion-icon> 
    </button> 
</ion-footer> 

2.Css代码

#ezarcontent { 
background-color: transparent !important; 
color: white !important; 
} 
  1. 打印稿代码

    public storeImg = [];

    takePhotos(){

    this.platform.ready(),然后(()=> {

    this.saveCameraImg().then(success => { 
    
        this.storeImg.push(success); 
    }, (error) => { 
    console.log(error); 
    }); 
    

    })。 }

    saveCameraImg(){无极

    return new Promise(function(resolve,reject){ 
    
        var win: any = window; 
        var ezar: any = win.ezar; 
        var snapshotBtn = document.getElementById("snapshot"); 
        var revCameraBtn = document.getElementById("revcamera"); 
        var inclWebView = true;  
        var inclCameraBtns = true; 
    
        if (inclWebView && !inclCameraBtns) { 
         revCameraBtn.classList.add("hide"); 
         snapshotBtn.classList.add("hide");    
        } 
        ezar.snapshot(
        function(base64EncodedImage) { 
         resolve(base64EncodedImage); 
        }, 
        function(error) { 
         alert("ezar snapshot failed"); 
        }, 
        {"saveToPhotoGallery": true, 
        "encoding": ezar.ImageEncoding.PNG, 
        "includeWebView": false, 
        "includeCameraView": true 
        } 
    ); 
    }); 
    

    }

回答

0

您的图像需要消毒模块,添加DomSanitizer在您的TS文件。该代码如下

import {DomSanitizer, SafeHtml, SafeStyle, SafeScript, 
SafeUrl,SafeResourceUrl} from '@angular/platform-browser'; 
    constructor(private sanitizer:DomSanitizer){} 

this.storeImg.push(this.sanitizer.bypassSecurityTrustUrl(<your response>)); 

我相信它绝对有效。