1

我正在用 Cordova/Ionic 构建一个应用程序。用户可以操纵他的画廊照片,然后将其显示在应用程序上。

我现在面临的问题是,操作后,图像不会显示在 Android > 4 设备(Android 4、Android 5、Android 6 等)上。只有一个“找不到图像”的图像可见。但在 Android 2.x 设备上一切正常。

这些版本之间是否有任何重大变化?

操作是通过这个插件完成的。

我的代码如下所示(index.html

<img src="{{!!image.img11 ? image.img11.src : 'img/layout/placeholder.png'}}" ng-cloak>

应用程序.js

      navigator.camera.getPicture(onSuccess, onFail,
      {
        quality: 30,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        targetWidth: imagePickerWidth,
        targetHeight: imagePickerHeight,
        encodingType: Camera.EncodingType.PNG,
        allowEdit: false
      });

      function onSuccess(imageURI) {
        self.crop(resolve, reject, scope, imageURI, type, width, height, tabs);

        /* JR-CROP MANIPULATION */

        scope.image.img11 = new Image();
        scope.image.img11.src = canvas.toDataURL("image/png");
      }
4

1 回答 1

0

好的,似乎在大于 5 (5,6,7) 的 Android 上需要security-policy.index.html header

只需添加以下内容:

<head>
<meta http-equiv="Content-Security-Policy" content="img-src 'self' data:;">
...
</head>

这允许base64显示编码图像。

于 2016-10-10T16:40:10.053 回答