首页 > 解决方案 > 路线 [people.comments] 未定义

问题描述

帮我找出问题,laravel项目在加载前给出错误

路线 [people.comments] 未定义

我复制并粘贴了路线名称,复制并粘贴了工作路线,但不,它不起作用。

    Route::post('/people/comments', 'Admin\PeopleController@comments')->name('people.comments');

当我将方法 POST 更改为 GET Route::get('/people/comments', 'Admin\PeopleController@comments')->name('people.comments');

我在 JAVASCRIPT 中使用这条路线

      let url = '{{ route("people.comments") }}';

现在的问题是为什么当我更改帖子以获得它时它会起作用?为什么它不能在 POST 中工作?(我没有同名的路线)谢谢

标签: laravelrouteslaravel-7laravel-routingnamed-routing

解决方案


这是我的错误两个帖子具有相同的地址和相同的方法

 Route::post('/people/comments', 'Admin\PeopleController@comments')->name('people.comments');
 Route::post('/people/comments', 'Admin\PeopleController@blogs')->name('people.blogs');

推荐阅读