laravel 中的新惯性路线返回 404

问题描述

我正在尝试在 Intertia 中为 Laravel 注册一条新路由,但除了第一条路由之外的所有内容都给了我 404。这些是我在 web.PHP 中的路由:

Route::get('/app',function () { return Inertia::render('Atlas/App'); });
Route::get('/test',function () { return Inertia::render('Test/Test'); });
Route::get('/test2',function () { return Inertia::render('Test/Test2'); });

Route::get('/',function () {
    return view('welcome');
});

这些是我的文件

App.vue:

<template>
<div>
    Test
</div>
</template>
<script>

export default {
    name: "App",props: ['sessions'],}
</script>

和Test.vue:

<template>
<div>
    Test
</div>
</template>
<script>

export default {
    name: "Test",}
</script>

下面你可以看到我的文件结构:

Structure

我试过多次运行 PHP artisan serve 和 npm run watch,没有任何变化。我错过了什么重要的东西吗?唯一有效的路径是 /test,它与 /test2 和 /app

基本相同

解决方法

您可以像这样使用 inertia Route helpers

Route::inertia('/app','Atlas/App');
Route::inertia('/test','Test/Test');
Route::inertia('/test2','Test/Test2');