【发布时间】:2022-11-17 15:24:10
【问题描述】:
我正在使用 Reactjs 并且正在使用 nextjs,现在我正在尝试集成/获取滑块数据,问题是我只想将类“活动”添加到第一张幻灯片,所以我正在尝试使用 {post.id},但是我如何使用条件(在 id="1" 处添加“活动”类)?那么我如何使用 loop/mapfunction 来做到这一点?这是我当前的代码
<div className={`carousel-item ${post.id === 1 ? 'active' : ''}`}>
<img src="img/blog-slider.png" className="d-block w-100" alt="..." />
<div className="carousel-caption d-md-block">
<h5>MBG starts Their Journey</h5>
<p>Along with collecting as much data and information as possible, completing their research, and making their plan, the MBG team has now begun to implement their plan in detail, and they are in the initial steps. With the completion of any step, the MBG team will inform you about the latest news and information</p>
</div>
</div>
【问题讨论】:
标签: javascript reactjs next.js