佚名通过本文主要向大家介绍了选择加盟应注意的问题,请选择问题类型,选择方案问题,金庸群侠传x问题选择,选择问题等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题:cordova cordova选择图片并显示的问题
描述:
解决方案1:
描述:
当我使用如下代码选取一张图片并显示的时候,图片无法显示。
提示的错误如下:
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 ng-style="verfyMediaImgCss" ng-repeat="media in data.verfyMedias">
<img ng-style="verfyMediaImgCss" ng-src="{{media.url}}"/>
</div>
解决方案1:
最好不要用file://,把文件拷到app目录下,然后用相对路径引用。
如果一定要用,需要用https://cordova.apache.org/docs/en/latest/guide/appdev/whitelist/打开对file://的访问权限。