【问题标题】:Ionic not loading images correctly & is whitelistedIonic 无法正确加载图像并被列入白名单
【发布时间】:2017-01-13 10:38:59
【问题描述】:

这是一个奇怪的问题,控制器循环遍历一个数组,该数组从服务器收集图像的 url,然后将其放入 src="https://www.socialnetwk.com/test.png" 但是它不会加载这些图像。我检查元素,右键单击 src=".." 并在新窗口中打开。一次在新窗口中,我刷新 ionic 应用程序页面,它会加载该图像,该图像只有我

.controller('feedCtrl', function($scope, $http) {
      $scope.result = "";
     $http.get('https://m.socialnetwk.com/home/app/feed_load.php').then(function(rest) {
        $scope.records = rest.data;
      });
    })

<div ng-repeat="feed in records">

    <ion-list id="search-list5">
      <ion-item class="item-avatar" id="search-list-item12">
        <img src="https://www.socialnetwk.com/media/{{feed.profile_image}}">
        <h2>{{feed.firstname}} {{feed.lastname}}</h2>
        <p>{{feed.location}}</p>
      </ion-item>
    </ion-list>
    <div style="margin: 0px; line-height: 250px; background-color: rgb(232, 235, 239); text-align: center;">
      <img style="width:100%;height:auto;" ng-src="https://www.socialnetwk.com/media/{{feed.media_file_format}}/{{feed.media_post_id}}{{feed.media_author_id}}.{{feed.media_file_format}}" />
    </div>
    <div class="item item-body" id="search-list-item-container3">
      <div id="search-markdown6" class="show-list-numbers-and-dots">
        <p style="margin-top:0px;color:#000000;">{{feed.mediatxt}}
        </p>
      </div>
    </div>
</div>

【问题讨论】:

  • 请在问题中添加您的 html 代码

标签: angularjs ionic-framework


【解决方案1】:

请确保在ng-src 中包含您的路径。如果你只是使用src,你会遇到麻烦。

<img ng-src="data.imageurl"/>

【讨论】:

    【解决方案2】:

    我已经在 Postman 中测试了您的 URL(https://m.socialnetwk.com/home/app/feed_load.php) 请求并得到了这个。

    [
    {
    "firstname": "Casper",
    "lastname": "Round",
    }
    ]
    

    所以你没有你需要的数据。

    检查网址。

    【讨论】:

    • 没有必要测试那个 url。当然它会改变我一直在编辑那个文件!
    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 2016-09-01
    • 1970-01-01
    • 2018-08-20
    • 2014-01-09
    • 2021-06-28
    • 2019-11-30
    • 1970-01-01
    相关资源
    最近更新 更多