如何写如果与laravel叶片在HTML div类


<!-- Wrapper for slides -->
<div class="carousel-inner">
@foreach($product as $item)
<!-- if id of item is one set to active if not to empty -->
<div class="item {{$item['id']== 1?'active':''}}">
<img src="la.jpg" alt="Chania">
<div class="carousel-caption ">
<h3>Los Angeles</h3>
<p>LA is always so much fun!</p>
</div>

@endforeach
</div>

我已经写了if条件,但是它不起作用我想把第一张幻灯片显示为活动

<!-- Wrapper for slides -->
<div class="carousel-inner">
@foreach($product as $item)
<!-- if id of item is one set to active if not to empty -->
<div class="item {{$item->id == 1 ? 'active': ''}}"> <!-- your id rendering caused it -->
<img src="la.jpg" alt="Chania">
<div class="carousel-caption ">
<h3>Los Angeles</h3>
<p>LA is always so much fun!</p>
</div>
</div>  <!-- closing div is needed as well -->
@endforeach
</div>

最新更新