如何设置图标的不同状态?我想让它在喜欢/不喜欢的图标之间切换。我能这样做吗?我不完全理解语法。 btn-success类用于喜欢的图标,而btn-danger用于unliked按钮。
@if(Auth::check())
@if( !$unblock )
<span data-id="{{ $key->id }}" data-like="Like" data-like-active="Remove Like" title="@if(!empty($likeUser)) Remove Like @else Like @endif" class="btn btn-xs pull-left @if(!empty($likeUser)) btn-success @else btn-danger @endif btn-like likeButton @if(!empty($likeUser)) active @endif">
<i class="Like-icon"></i>
</span>
@else
答案 0 :(得分:2)
你在@else
Here是了解有关刀片和模板的更多信息的地方
就像普通的PHP if..else
条件
@if (Auth::check())
Authorized
@else
Nope
@endif
如果你想在其中有其他条件
@if (Auth::check())
Authorized
//your additional conditions for authorized users
@else
Nope
@endif
答案 1 :(得分:1)
@if (count($records) === 1)
I have one record!
@elseif (count($records) > 1)
I have multiple records!
@else
I don't have any records!
@endif