Route::get('user/profile', function () {
return 'test' })->name('profile');
但是当我拨打地址/个人资料时,我总是会收到错误 如果我使用地址/用户/配置文件,它的工作正常。
我的浏览器中显示的错误列表:
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 821
at Router->findRoute(object(Request)) in Router.php line 691
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
我在哪里错过? 提前谢谢。
答案 0 :(得分:0)
您需要将路线从user/profile
更改为profile
Route::get('profile', function () {
return 'test' })->name('profile');
name()
仅为不更改URL的路径创建别名
答案 1 :(得分:0)
Route::get('user/profile', function () {
return 'test'; })->name('profile');
试试This.Hope它会起作用!!