如何在 Vue.js 和 Laravel 5.4 中发出 POST 请求
How to make a POST Request in Vue.js and Laravel 5.4
如何消除此错误以及如何检索通过 POST 请求在 Vue.js
中传递的数据
这是我的app.js
,只关注红色框。
添加此代码以启用 csrf_token。
这是Route
我想要得到的回应
这是我的Controller
这就是我遇到的错误。
我想知道我的代码中缺少什么或有什么错误。我需要你的帮助。
您收到 MethodNotAllowedException
是因为您定义了 GET
路线但需要 POST
路线。
尝试使用
Route::post('page-send-message', 'MainController@send');
而不是
Route::get('page-send-message', 'MainController@send');
无论如何,建议使用 axios 库而不是 Vue post 请求。有关详细信息,请查看 laravel
的 bootstrap.js
如何消除此错误以及如何检索通过 POST 请求在 Vue.js
中传递的数据这是我的app.js
,只关注红色框。
添加此代码以启用 csrf_token。
这是Route
我想要得到的回应
这是我的Controller
这就是我遇到的错误。
我想知道我的代码中缺少什么或有什么错误。我需要你的帮助。
您收到 MethodNotAllowedException
是因为您定义了 GET
路线但需要 POST
路线。
尝试使用
Route::post('page-send-message', 'MainController@send');
而不是
Route::get('page-send-message', 'MainController@send');
无论如何,建议使用 axios 库而不是 Vue post 请求。有关详细信息,请查看 laravel
的 bootstrap.js