它们使用jetStream InertiaJ设置了一个新的laravel8项目,但当我启动应用程序时,我得到了以下错误:

显然,这是一个路由错误,博客显示了编辑RouteServiceProvider.php文件并定义以下变量的解决方案:
protected $namespace = 'App\\Http\\Controllers';$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});web文件路径如下:
Route::get('/', function () {
return Inertia::render('Welcome', [
'canLogin' => Route::has('login'),
'canRegister' => Route::has('register'),
'laravelVersion' => Application::VERSION,
'phpVersion' => PHP_VERSION,
]);
});
Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
return Inertia::render('Dashboard');
})->name('dashboard');但是错误仍然存在,请有人告诉我一个解决方案,或者我应该检查一下以找到解决方案
发布于 2021-01-12 15:34:57
在使用它之前,您可能需要在PHP文件的顶部执行use Inertia\Inertia;。
发布于 2021-04-09 09:26:03
按照此处的说明进行操作:https://inertiajs.com/server-side-setup
composer require inertiajs/inertia-laravel
php artisan inertia:middleware那么就应该找到这个类。注意到这个类不能在IDE中解析,所以假设它不是默认安装的。
发布于 2021-03-14 11:28:06
基于这个错误,你可能遗漏了App前面的一个反斜杠。将其放入web.php文件中,如下所示:\App\Http\Middleware\HandleInertiaRequests::class
https://stackoverflow.com/questions/65675690
复制相似问题