目前我有一个容器,它以特定模式保存我的图像,其中第 1 张和第 6 张卡片水平拉长,卡片 2 到 5 垂直拉长。到目前为止,所有这些图像都是硬编码的,但我想要一个 .map 函数来从我的后端获取数据。但问题是 .map 需要 1 个布局并复制它,但我希望它遵循我认为需要循环的特定模式。
CodeSandbox:https ://codesandbox.io/s/gallant-forest-vygnw ? file =/ src/App.js
代码:
<div className="container">
<div className="row">
{/* {posts &&
posts.map((item) => ( */}
<div className="col-md-6 col-sm-6">
<div className="row">
<div className="col-md-12">
<img src="https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg" />
</div>
</div>
<div className="row">
<div className="col-md-6 col-sm-6">
<img
style={{ minHeight: "280px", objectFit: "cover" }}
src="https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg"
/>
</div>
<div className="col-md-6 col-sm-6">
<img
style={{ minHeight: "280px", objectFit: "cover" }}
src="https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg"
/>
</div>
</div>
</div>
<div className="col-md-6 col-sm-6">
<div className="row">
<div className="col-md-6 col-sm-6">
<img
style={{ minHeight: "280px", objectFit: "cover" }}
src="https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg"
/>
</div>
<div className="col-md-6 col-sm-6">
<img
style={{ minHeight: "280px", objectFit: "cover" }}
src="https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg"
/>
</div>
</div>
<div className="row">
<div className="col-md-12">
<img src="https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg" />
</div>
</div>
</div>
{/* ))} */}
</div>
</div>