【问题标题】:Image is not displaying in device in IONIC 4 from server in android version 9 and above图像未显示在 IONIC 4 的设备中,来自 android 版本 9 及更高版本的服务器
【发布时间】:2020-07-09 00:54:10
【问题描述】:

我想显示类别列表。

Android 9 及以上版本不显示图像。
当我尝试放置静态图像时,它显示完美,但未显示来自服务器的图像。

在离子服务上,它按预期显示图像。

回复:

[{"categoryId":"1","name":"常规 知识","图片":"http://codehub.biz/knowledgeup/API/images/gk_categaries_icons.png"},{"categoryId":"3","name":"生物学","图片":" http://codehub.biz/knowledgeup/API/images/biology_categaries_icons.png"},{"categoryId":"4","name":"Chemistry","image":"http://codehub.biz/ Knowledgeup/API/images/Chemastry_Categaries_Icons.png"},{"categoryId":"5","name":"Economy","image":"http://codehub.biz/knowledgeup/API/images/Economy。 png"},{"categoryId":"6","name":"Sports","image":"http://codehub.biz/knowledgeup/API/images/sports_categaries_icons.png"},{"categoryId" :"7","name":"Physics","image":"http://codehub.biz/knowledgeup/API/images/physics.png"},{"categoryId":"8","name" :“世界 地理","图片":"http://codehub.biz/knowledgeup/API/images/geo.png"},{"categoryId":"10","name":"科学 & 发明","图片":"http://codehub.biz/knowledgeup/API/images/science.png"}]

tab1.html

<ion-grid>
  <ion-row  class="margin" *ngFor="let row of grid">
    <ion-col size="3" class="ion-text-center" *ngFor="let item of row" (click)="quizInfo(item.categoryId,item.name)">
      <img class="logo" [src]='item.image'> <br>
      <!-- <img src="../../assets/icon/bio.png" class="logo"> <br> -->
      <p class="margin title">{{item.name}}</p>
    </ion-col>
  </ion-row>
</ion-grid>

这是我用于显示列表的 html。

图片未显示
第一张图片是 android 版本 9 和 android 版本 7

【问题讨论】:

  • 你添加的图片是以http://...的形式保存在db中还是只是图片名称?

标签: android angular image ionic-framework ionic4


【解决方案1】:

问题是http请求。
图片路径以 http 开头。
为了安全起见,Android pie 不接受没有 https 请求的 API 请求。

【讨论】:

    【解决方案2】:

    问题是上面的android 9默认只接受HTTPS调用。但是你可以绕过 将此添加到您的Androidmanifest.xmlandroid:usesCleartextTraffic="true"

    <application
        android:usesCleartextTraffic="true" // -->here
        android:allowBackup="true"
        ...
        >
    

    但建议只使用 HTTPS

    【讨论】:

      猜你喜欢
      • 2020-06-27
      • 2020-03-09
      • 2016-09-13
      • 1970-01-01
      • 2012-11-24
      • 1970-01-01
      • 2016-12-20
      • 2018-06-19
      • 2021-03-23
      相关资源
      最近更新 更多