Laravel 为什么post表单没有运行请求的路由?
我得到了一个对路由的简单POST请求,但由于某种原因,该方法没有被处理 web.phpLaravel 为什么post表单没有运行请求的路由?,laravel,forms,post,Laravel,Forms,Post,我得到了一个对路由的简单POST请求,但由于某种原因,该方法没有被处理 web.php Route::get('/',[clockController::class,'index']); 路由::post('/',[clockController::class,'timerTimezoneValue'])->名称('timerTimezoneValue'); clockController.php 类clockController扩展控制器{ 公共职能指数(){ $timezoneData=时
Route::get('/',[clockController::class,'index']);
路由::post('/',[clockController::class,'timerTimezoneValue'])->名称('timerTimezoneValue');
clockController.php
类clockController扩展控制器{
公共职能指数(){
$timezoneData=时区::get(['timezone\u value','timezone\u region','timezone\u city']);
$date=日期(“H:i”);
$timezone=date\u default\u timezone\u get();
$completeDate=$date.“$时区;
$city=true;
返回视图('clockManagement/clockMain',compact('timezoneData','completeDate','city');
}
公共函数timerTimezoneValue(请求$timezoneValue){
dd($timezoneValue->all());
返回视图('clockManagement/clockMain',compact('timezoneData','completeDate','city');
}
}
表格:
@csrf
{{--时区--}
@foreach($timezoneData作为$timezone)
{{$timezone->timezone_city}
@endforeach
怒火
基本上,表单应该发送一个带有选项值的post请求到
timerTimezoneValue
,但该方法没有打开。通过安装新的laravel框架并移动控制器、视图等来修复该问题。不确定是什么导致了该问题,但现在很好按下提交按钮时发生了什么?您可以在inspect Element中检查网络抽头Laravel的哪个版本?日志里什么都没有?您是否尝试过[\App\Http\Controllers\clockController::class'timerTimezoneValue']
?提交后,将打开默认页面,就像处理了索引方法一样。我使用的是最新的laravel版本(8.42.1)。更改为[\App\Http\Controllers\clockController::class'timerTimezoneValue']
时出错。以下是网络截图: