实现有多个图片的遍历显示react

如图要想实现这个效果,首先这些图片是存储在一个数组中的,我们要取出图片然后遍历显示出来,可以如下显示:

render: (text) => {
if (text && text.length) {
const imgs = text.map((item, index) =>
<div key={index} style={{ backgroundImage: `url(${item.mediaUrl})` }} className='bg-cover teacher-medias' />
)
return <div style={{ display: 'flex' }}>{imgs}</div>
}
}

相关文章:

  • 2022-01-08
  • 2022-01-16
  • 2021-08-30
  • 2021-10-15
  • 2021-07-24
  • 2021-08-08
  • 2021-12-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-10-26
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案