search

Home  >  Q&A  >  body text

javascript - ionic 中使用 cordova camera 插件选择本地图片显示问题

OS 环境是安卓5.1.1,ionic版本是1.1,cordova版本是5.4.1
使用ngCordova中的camera插件选取本地照片并显示在页面中,图片选择没有问题,用chrome调试的时候dom中已经存在img元素并且src是选中的图片,图片资源也加载完成了,但是界面中就是不显示img的图像,整个界面就像是block住了。以下是部分代码:

HTML

<img ng-repeat="image in imageList" ng-src="{{image}}"
                 width="100" height="100"
                style="padding: 5px;">

JS

var options = {
                destinationType: Camera.DestinationType.FILE_URI,
                sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
                saveToPhotoAlbum: true,
                targetWidth: 800,
                targetHeight: 800
            };
            navigator.camera.getPicture(function (imageURI) {
                $timeout(function () {
                    $scope.imageList.push(imageURI);
                });
            }, function (error) {
                //error handle
                console.log("Error: " + error);
            }, options);
PHPzPHPz2902 days ago302

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-10 16:48:52

    更新到ionic 1.2 之后问题解决了

    reply
    0
  • 阿神

    阿神2017-04-10 16:48:52

    这个问题你解决了么,我现在好像也遇到这个问题了,选择图片后页面不显示,第二次点击按钮上一次选择的图片就显示了

    reply
    0
  • PHPz

    PHPz2017-04-10 16:48:52

     试试这样的h5代码:

    <p ng-repeat="image in imageList">
        <img ng-src="{{image}}" width="100" height="100" style="padding: 5px;">
    </p>
    

    reply
    0
  • Cancelreply