简体   繁体   English

图像未显示在 IONIC 4 的设备中,来自 android 9 及更高版本的服务器

[英]Image is not displaying in device in IONIC 4 from server in android version 9 and above

I want to show list of categories.我想显示类别列表。

Image is not shown on android version 9 and above.图像未显示在 android 9 及更高版本上。
when I try to put static image it shows perfectly but image from server is not shown.当我尝试放置静态图像时,它显示完美,但未显示来自服务器的图像。

On ionic serve it is showing image as expected.在离子服务上,它按预期显示图像。

Response:回复:

[{"categoryId":"1","name":"General Knowledge","image":"http://codehub.biz/knowledgeup/API/images/gk_categaries_icons.png"},{"categoryId":"3","name":"Biology","image":"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":"World Geography","image":"http://codehub.biz/knowledgeup/API/images/geo.png"},{"categoryId":"10","name":"Science & Inventions","image":"http://codehub.biz/knowledgeup/API/images/science.png"}] [{"categoryId":"1","name":"一般知识","image":"http://codehub.biz/knowledgeup/API/images/gk_categaries_icons.png"},{"categoryId":" 3","name":"Biology","image":"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":"世界地理","image":"http://codehub.biz/knowledgeup/API/images/geo.png"},{"categoryId ":"10","name":"科学与发明","image":"http://codehub.biz/knowledgeup/API/images/science.png"}]

tab1.html 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>

This is my html for displaying list.这是我用于显示列表的 html。

Image is not shown图像未显示
1st image is of android version 9 and is android version 7第一张图片是 android 版本 9,是 android 版本 7

在此处输入图片说明 在此处输入图片说明

The problem is http request.问题是http请求。
Image path start with http.图像路径以 http 开头。
Android pie don't accept API requests without https requests for security.出于安全考虑,Android pie 不接受没有 https 请求的 API 请求。

the problem is that android 9 above by default only accepts HTTPS calls.问题是上面的 android 9 默认只接受 HTTPS 调用。 But you can bypass add this to your Androidmanifest.xml : android:usesCleartextTraffic="true"但是您可以绕过将其添加到您的Androidmanifest.xmlandroid:usesCleartextTraffic="true"

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

But its recommend to use only HTTPS但它建议只使用 HTTPS

Do you solve the problem?你解决问题了吗? I have the same issue我有同样的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM