html-Ionic 4动态照片url不起作用-未显示图像

前端之家收集整理的这篇文章主要介绍了html-Ionic 4动态照片url不起作用-未显示图像 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在我的应用程序中,我正在这样做:

<ion-col *ngFor ="let place of intentList,let photo of photoList">
        <ion-card>
          <ion-card-content>
          <img class="img" src = "{{photo}}" (click)="clickedImage(place.intent)">
          <div>{{place.val}}</div>
          </ion-card-content>
        </ion-card>
      </ion-col>

数组photoList包含具有不同照片URL的字符串.这是数组:

this.photoList = ["./assets/images/001-breakfast.png","./assets/images/002-brunch.png","./assets/images/003-sandwich.png","./assets/images/004-food.png","./assets/images/005-dinner.png","./assets/images/006-cake.png","./assets/images/007-cocktail.png"]

但这是我的应用程序的外观:

enter image description here

最佳答案
<ion-col *ngFor ="let place of intentList; let i=index;">
        <ion-card>
          <ion-card-content>
          <img class="img" src = "{{photo[i]}}" (click)="clickedImage(place.intent)">
          <div>{{place.val}}</div>
          </ion-card-content>
        </ion-card>
      </ion-col>

您可以使用index实现:

原文链接:https://www.f2er.com/html/530416.html

猜你在找的HTML相关文章