Laravel叶片模板中的条件结构不';行不通
我在laravel模板中有一个具有不同颜色的css类如何在laravel刀片上使用嵌套的三元运算符?我尝试了几种方法,但都不起作用,例如,它使用“if语句”,但不起作用Laravel叶片模板中的条件结构不';行不通,laravel,laravel-blade,Laravel,Laravel Blade,我在laravel模板中有一个具有不同颜色的css类如何在laravel刀片上使用嵌套的三元运算符?我尝试了几种方法,但都不起作用,例如,它使用“if语句”,但不起作用 <td rowspan="{{count($awards)+1}}" class="@if ($awards === 'DIAMOND') bg-white text-dark @elseif ($awards === 'RUBY') bg
<td
rowspan="{{count($awards)+1}}"
class="@if ($awards === 'DIAMOND')
bg-white text-dark
@elseif ($awards === 'RUBY')
bg-danger text-white
@elseif ($awards === 'EMERALD')
bg-success text-white
@else
bg-white text-dark
@endif">
{{$award}}
</td>
{{$award}
它将类似于:
<td rowspan="{{count($awards)+1}}"
class="
@foreach($awards as $award)
@if ($award->color === 'DIAMOND')
bg-white text-dark
@elseif ($award->color === 'RUBY')
bg-danger text-white
@elseif ($award->color === 'EMERALD')
bg-success text-white
@else
bg-white text-dark
@endif">
{{ $award->color }}
@endforeach
</td>
{{$award->color}
@endforeach
它将类似于:
<td rowspan="{{count($awards)+1}}"
class="
@foreach($awards as $award)
@if ($award->color === 'DIAMOND')
bg-white text-dark
@elseif ($award->color === 'RUBY')
bg-danger text-white
@elseif ($award->color === 'EMERALD')
bg-success text-white
@else
bg-white text-dark
@endif">
{{ $award->color }}
@endforeach
</td>
{{$award->color}
@endforeach
您也可以使用括号在类似刀片的面板上嵌套三元
<html>
{{$firstQuestion ? (secondQuestion ? $isTrue ? $isFalse) : ($doAnother ? $isTrue : $isFalse}}
</html>
您也可以使用括号在类似刀片的对象上嵌套三元
<html>
{{$firstQuestion ? (secondQuestion ? $isTrue ? $isFalse) : ($doAnother ? $isTrue : $isFalse}}
</html>
$awards
是数组还是变量?$awars是数组中的键$awards
是数组还是变量?$awars是数组中的键