我正在使用cordova插件相机来显示图像,如果destinationType是DATA_URL它可以正常工作
.TS:
getPic(){
const options: CameraOptions = {
quality: 100,
sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: this.camera.DestinationType.FILE_URI
}
this.camera.getPicture(options).then((imageData) => {
this.success = 'getting image is successful';
this.Image = imageData;
}, (err) => {
this.err = err;
});
}
html:
<button ion-button primary (click)="getPic()">get picture</button>
<img src="{{Image}}" />
<p>this is image: {{Image}}</p> //Output -> content://media/external/images/media/1022
<p>{{success}}</p>
<p>{{err}}</p>
我还将此添加到index.html但仍无法正常工作<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">