1
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

我想念哪里?提前致谢。

4

2 回答 2

0
Route::get('user/profile', function () {
return 'test'; })->name('profile');

试试This.Hope它会工作!

于 2016-09-28T13:39:08.670 回答
0

您需要将路线从更改user/profileprofile

Route::get('profile', function () {
   return 'test' })->name('profile');

name()仅为路由创建别名而不更改 URL

于 2016-09-28T13:36:08.630 回答