当我使用如下代码选取一张图片并显示的时候,图片无法显示。
提示的错误如下:
Not allowed to load local resource: file:///var/mobile/Containers/Data/Application/6D3021AE-C57B-4812-AA47-62881A922CB7/tmp/cdv_photo_002.jpg
$cordovaImagePicker.getPictures(options)
.then(function(results) {
if ($scope.data.verfyMedias == undefined ||
$scope.data.verfyMedias == null) {
$scope.data.verfyMedias = [];
}
if (results.length < 1)
return;
var media = { url: results[0], type: 0 };
$scope.data.verfyMedias.push(media);
}, function(error) {
});
<div style="float:left;" ng-style="verfyMediaImgCss" ng-repeat="media in data.verfyMedias">
<img ng-style="verfyMediaImgCss" ng-src="{{media.url}}"/>
</div>
最好不要用file://,把文件拷到app目录下,然后用相对路径引用。
如果一定要用,需要用https://cordova.apache.org/docs/en/latest/guide/appdev/whitelist/打开对file://的访问权限。