我正在使用依賴項react-responsive-carousel 中的React Carousel來顯示用戶上傳到 firebase 的影像我查詢陣列中的影像,例如:
image: [imageUrl/0, imageUrl/1, imageUrl/2, imageUrl/3, imageUrl/4] // Maximum is 5
//then display it like
<Carousel
infiniteLoop
showStatus={true}
showIndicators={true}
showThumbs={true}
>
<div>
<img src={imagesUrl[0]} alt="title"/>
</div>
<div>
<img src={imagesUrl[1]} alt="title"/>
</div>
<div>
<img src={imagesUrl[2]} alt="title"/>
</div>
<div>
<img src={imagesUrl[3]} alt="title"/>
</div>
<div>
<img src={imagesUrl[4]} alt="title" />
</div>
</Carousel>
它作業正常但是當用戶上傳 3 張影像時,它將顯示 5 張影像,最后 2 張將是空白影像,是否可以以只顯示陣列中內容的方式映射陣列?
uj5u.com熱心網友回復:
您可以遍歷影像并顯示它們:
使用地圖:
...
images.map((image) => {
return <div>
<img src={image} alt="title" />
</div>
})
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/353996.html
標籤:javascript 反应 火力基地 响应式轮播
上一篇:如何用正則運算式替換所有出現的
下一篇:根據回應在反應中顯示影像
