php - 路由 [admin.index] 未定义
问题描述
使用 Laravel 5.8,我有以下 href 链接,
href="{{route('admin.index')}}"
而我的 web.php 路由是这样的,
Route::get('/admin.index', function () {
return view('admin.index')->name('admin.index');
});
但我在这里收到以下错误消息
Route [admin.index] not defined. (View: F:\2020 technologies\laravel\bestbrandtoday\resources\views\_includes\nav\admin.blade.php)
我该如何解决这个问题?
解决方案
名称在路由上,而不是在响应上:
Route::get('/admin.index', function () {
return view('admin.index');
})->name('admin.index');
附带说明一下,您的实际路线可能不应该有句号,因此您可以只使用/admin
或/admin/index