这是我的路线<?php/*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider within a group which| contains the "web" middleware group. Now create something great!|*/Route::get('/', function () { return view('welcome');});Route::get('/account', 'AccountController@index')->name('account.index')->middleware('auth');Route::get('/dashboard', 'DashboardController@index')->name('dashboard.show')->middleware('auth');在我的仪表板上<div class="main-menu-content"> <ul class="navigation navigation-main" id="main-menu-navigation" data-menu="menu-navigation"> <li {{ request()->route()->getName() === 'dashboard.index' ? ' class=active' : '' }}><a href="/dashboard"><i class="ft-home"></i><span class="menu-title" data-i18n="">Dashboard</span></a> </li> <li {{ request()->route()->getName() === 'account.index' ? ' class=active' : '' }}><a href="/account"><i class="ft-user"></i><span class="menu-title" data-i18n="">Account</span></a> </li> </ul> </div>我在这里要做的是使li课程处于活动状态,但是我尝试了上面的代码,尽管我在仪表板上但没有活动课程,而且我还检查了我在帐户中时li仍然没有突出显示为活动的。有人可以告诉我有什么问题吗?
2 回答
守着一只汪
TA贡献1872条经验 获得超3个赞
您没有命名帐户路由,因此您必须将帐户路由更改为:
Route::get('/account', 'AccountController@index')->name('account.index')->middleware('auth');
您确实将仪表板路由命名为dashboard.show
,因此li
仪表板的标签必须等于dashboard.show
而不是dashboard.index
婷婷同学_
TA贡献1844条经验 获得超8个赞
<li class="@if(Route::currentRouteName() == 'dashboard.show' active @endif"><a href="/dashboard"><i class="ft-home"></i><span class="menu-title" data-i18n="">Dashboard</span></a>
- 2 回答
- 0 关注
- 136 浏览
添加回答
举报
0/150
提交
取消