Setting Bootstrap navbar active class in Laravel 5

前端 未结 13 2108
温柔的废话
温柔的废话 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 16:52

    If you are working with named routes. You can use this approach in your views:

    {{ Route::currentRouteNamed('about') ? 'active' : '' }}
    

    or

    {{ Route::is('about') ? 'active' : '' }}
    

    The Illuminate\Routing\Router#is(...) is an alias of the Illuminate\Routing\Router#currentRouteNamed(...).

提交回复
热议问题