我正在检查刀片模板中的路由,以li
使用以下代码将活动类添加到我的菜单中的特定类:
<ul>
<li class="{{ Request::is('*/sobre') || Request::is('*') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/sobre" }}">Sobre o salão</a>
</li>
<li class="{{ Request::is('*/servicos') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/servicos" }}">Serviços</a>
</li>
<li class="{{ Request::is('*/avaliacoes') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/avaliacoes" }}">Avaliações</a>
</li>
<li class="{{ Request::is('*/galeria') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/galeria" }}">Fotos</a>
</li>
</ul>
这些是路线:
Route::group(['prefix' => '{domain}', 'middleware'=>'salao'], function () {
Route::get('/', 'Frontend\FrontendSalaoController@sobre');
Route::get('sobre', 'Frontend\FrontendSalaoController@sobre');
Route::get('servicos', 'Frontend\FrontendSalaoController@servicos');
Route::get('avaliacoes', 'Frontend\FrontendSalaoController@avaliacoes');
Route::get('galeria', 'Frontend\FrontendSalaoController@galeria');
});
当我访问 routehttp://website/x
或 routehttp://website/x/sobre
时,活动类的位置正确。但是,如果我访问该http://website/x/servicos
路由,则该类将添加到第一个 li 和servicos
li 中。
我该如何处理?