我做了一个喜欢/Collection 按钮(心形),当你点击它时,它会变成蓝色.这很好,除了当你点击另一个心形时,第一个蓝色的心形会再次变成白色,只有最后一个点击的心形会变成蓝色.
每次你点击另一颗心时,只有最后一颗点击的心会变成蓝色!其余的都很好,但我不知道为什么会这样.有人知道吗?
class Products extends Component
{
public $orderBy;
public $vacid;
public function mount()
{
$this->orderBy = "Sorteer: Nieuwste Vacatures";
if(Auth::id()) {
$user = Auth::user();
$fav = Favoriet::where('user_id','=',$user->id)->get();
foreach($fav as $fav){
$this->vacid = $fav->vacature_id;
}
}
}
@if($vac->id == $vacid)
<a class="bi bi-heart-fill fa-lg m-2" href="{{url('favorieten',$vac->id)}}"
data-tooltip="tooltip" data-placement="top" title="Voeg toe aan favorieten">
</a>
@else
<a class="bi bi-heart fa-lg m-2" href="{{url('favorieten',$vac->id)}}"
data-tooltip="tooltip" data-placement="top" title="Voeg toe aan favorieten">
</a>
@endif
<div class="border"></div>
@endforeach
</div>