Javascript 爱奥尼亚V2 Ezar相机拍摄快照返回base64,不存储在阵列中
我将尝试一些解决方案,但无法在阵列中存储base64 1.Html代码Javascript 爱奥尼亚V2 Ezar相机拍摄快照返回base64,不存储在阵列中,javascript,typescript,ionic2,cordova-plugins,angular2-forms,Javascript,Typescript,Ionic2,Cordova Plugins,Angular2 Forms,我将尝试一些解决方案,但无法在阵列中存储base64 1.Html代码 <ion-content padding id="ezarcontent"> </ion-content> <ion-footer> <button ion-button color="danger" (click)="takePhotos()"> <ion-icon name="camera"></ion-icon> </b
<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>
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
}
);
});
}您的图像需要sanitizer模块,请在ts文件中添加DomSanitizer。代码如下
import {DomSanitizer, SafeHtml, SafeStyle, SafeScript,
SafeUrl,SafeResourceUrl} from '@angular/platform-browser';
constructor(private sanitizer:DomSanitizer){}
this.storeImg.push(this.sanitizer.bypassSecurityTrustUrl(<your response>));
import{DomSanitizer,SafeHtml,SafeStyle,SafeScript,
SafeUrl,SafeResourceUrl}来自“@angular/platform browser”;
构造函数(私有sanitizer:DomSanitizer){}
this.storeImg.push(this.sanitizer.bypassSecurityTrustUrl());
我相信它肯定能起作用
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
}
);
});
import {DomSanitizer, SafeHtml, SafeStyle, SafeScript,
SafeUrl,SafeResourceUrl} from '@angular/platform-browser';
constructor(private sanitizer:DomSanitizer){}
this.storeImg.push(this.sanitizer.bypassSecurityTrustUrl(<your response>));