无法使用FILE_URI显示图像

时间:2017-04-01 09:08:32

标签: angular ionic-framework ionic2

我正在使用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 *">

0 个答案:

没有答案