[英]Geting route error while creating ecommerce site in laravel
I am trying to create an e-commerce site in Laravel. getting this error:我正在尝试在 Laravel 中创建一个电子商务网站。出现此错误:
Invalid route action: [HomeComponent]
.无效的路由操作:
[HomeComponent]
。
I am getting errors like this:我收到这样的错误:
at F:\xampp\htdocs\lv8ecom\vendor\laravel\framework\src\Illuminate\Routing\RouteAction.php:92
在
F:\xampp\htdocs\lv8ecom\vendor\laravel\framework\src\Illuminate\Routing\RouteAction.php:92
88▕ */
89▕ protected static function makeInvokable($action)
90▕ {
91▕ if (! method_exists($action, '__invoke')) {
➜ 92▕ throw new UnexpectedValueException("Invalid route action: [{$action}].");
93▕ }
94▕
95▕ return $action.'@__invoke';
96▕ }
i HomeComponent
was not found: Controller class HomeComponent
for one of your routes was not found. i
HomeComponent
未找到:Controller HomeComponent
未找到您的其中一条路线的 HomeComponent。 Are you sure this controller exists and is imported correctly?您确定这个 controller 存在并且导入正确吗?
1 F:\xampp\htdocs\lv8ecom\vendor\laravel\framework\src\Illuminate\Routing\RouteAction.php:47
Illuminate\Routing\RouteAction::makeInvokable("HomeComponent")
2 F:\xampp\htdocs\lv8ecom\vendor\laravel\framework\src\Illuminate\Routing\Route.php:191
Illuminate\Routing\RouteAction::parse("/", ["HomeComponent", "HomeComponent"])
This error is saying that the route is not found, you can use your routes like this:这个错误是说找不到路由,你可以像这样使用你的路由:
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index']);
Route::get
= the request method type example (get / post / put / delete)
Route::get
= 请求方法类型示例(get / post / put / delete)
/home
= the link you would like to access and call the controller at /home
= 您要访问的链接并拨打 controller
App\Http\Controllers\HomeController::class
= the controller name, you should create this file and name it as you like App\Http\Controllers\HomeController::class
= controller 名称,您应该创建这个文件并根据您的喜好命名
'index'
= the name of the method inside of the controller 'index'
= controller里面的方法名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.