【问题标题】:ionic v3 unable to display image from url - ion-imgionic v3 无法显示来自 url 的图像 - ion-img
【发布时间】:2018-04-07 21:43:12
【问题描述】:

我正在开发 ionic 版本 3 应用程序。

我无法显示从 http 请求中获取的图像。我不知道为什么,获取了图像的 url 但未显示。只有当我转到另一个页面并返回时才会显示它。

这是我的代码:

home.ts

  this.myapi.request('parent_student_info',data)
    .then(res =>{
        this.studentsarray = []
        this.studentsarray.push({
            id : response.employees[i].id,
            name: response.employees[i].first_name + " " + response.employees[i].last_name,
            face_image: response.employees[i].face_image_small
        })    

home.html

  <ion-list *ngFor="let student of studentsarray" no-lines>
      <ion-row padding-left>
        <ion-col>                
            <ion-img width="70" height="70" src="{{student.face_image}}"></ion-img>
        </ion-col>
        <ion-col>
          {{student.name}}
        </ion-col>
      </ion-row>
  </ion-list>

如何确保图像已加载?是不是因为请求导致获取url延迟?

【问题讨论】:

    标签: image rest ionic-framework ionic3


    【解决方案1】:

    我建议尝试使用普通的 img 标签而不是 ion-img。

    【讨论】:

    • 你是对的,这个 ion-img 标签太糟糕了。我让它与 img 一起使用,但有没有办法让它与 ion-img 一起使用
    • 据我所知, ion img 将在我们有 virtual scroll 时使用。它在文档中也这么说。 ionicframework.com/docs/api/components/img/Img/#img
    猜你喜欢
    • 2018-08-20
    • 2021-10-16
    • 2019-07-08
    • 1970-01-01
    • 1970-01-01
    • 2021-09-25
    • 2018-11-26
    • 2014-06-04
    相关资源
    最近更新 更多