我正在检查我的刀片模板中的路由,使用以下代码将活动类添加到菜单中的特定li:
原文链接:https://www.f2er.com/regex/356599.html<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'); });
当我访问路线http:// website / x或路线http:// website / x / sobre时,活动类正确定位.但是,如果我访问http:// website / x / servicos路由,该类将添加到第一个li和servicos li中.
我怎么处理这个?