angular - 角度图像列表
问题描述
我有一个包含 src 和标题的数组。我需要在通过数组循环的列表中显示图像。
IMAGES = [
{
src: 'https://material.angular.io/assets/img/examples/shiba2.jpg',
caption: 'It\'s a thing',
},
{
src: 'https://picsum.photos/200',
caption: 'This is a really long string to see how the text will overflow',
},
{
src: 'https://picsum.photos/200',
caption: 'It\'s a thing',
},
{
src: 'https://picsum.photos/200',
caption: 'It\'s a thing',
},
{
src: 'https://picsum.photos/200',
caption: 'It\'s a thing',
},
{
src: 'https://picsum.photos/200',
caption: 'It\'s a thing',
}
];
解决方案
请检查以下代码,您可以使用 div 和内部 div img 标签。
<div *ngFor="let image of IMAGES">
<img [src]="image.src" [attr.alt]="image.caption" [attr.title]="image.caption" width="100" height="100">
</div>
推荐阅读
- c++ - 分段错误 - 读取初始化指针数组
- django - 如何在 django 中为我的产品模型上传多个图像?
- c# - 用户是否可以转义 asp.net core 的应用程序文件夹?
- facebook - 通过 Facebook 广告获取 Branch 的 Deeplink 键值
- visual-studio - 使用 xam.Plugin.DownloadManager Xamarin 表单
- hdfs - 如何使用 Apache Flink 读取 HDFS 中的 parquet 文件?
- chisel - 运行baremetal或pk程序时,双核验证器中只有一个Core ACTIVE
- python - MNIST - 数据集准备
- java - 在正则表达式匹配方面需要帮助
- javascript - .join ( ) 仅适用于 console.log ( )