Setting Bootstrap navbar active class in Laravel 5

前端 未结 13 2046
温柔的废话
温柔的废话 2020-12-23 16:34

I\'ve been wondering around looking for solutions, but can\'t really understand especially when creating helpers. I\'m new in Laravel and I want a simple or if not a detaile

13条回答
  •  感情败类
    2020-12-23 17:01

    Your code is working fine, but you have to use it for every link that can be active. It is better to return only class name, not class="..." so you can add other classes.

    Be careful when using * at the end (about*). If you use /* for home page then it will always be marked as active (because every other page starts with /).

    
    

    You can also move {{ Request::is('/') ? 'active' : '' }} to helper function/method.

提交回复
热议问题