我已经安装了带有 Inertia 的 Jetstream。我注册一个用户,然后尝试登录,控制台给出以下错误:
[Vue warn]: Error in render: "TypeError: _vm.$page.user is null"
当我查看控制器的响应时,它确实不包含用户。
用户附着在哪里?大概在一些中间件中。但哪个?
以下是显示该问题的两个 Web 路由。请注意中间件的差异。
Route::middleware(['auth'])->get('/dashboard', function () {
return Inertia\Inertia::render('Dashboard');
})->name('dashboard');
Route::get('/map', [MapController::class, 'show'])->name('map');
我也尝试过中间件auth:sanctum
and verified
.
您对用户的看法是正确的。它附在ShareInertiaData
Jestream 提供的中间件。
假设您将惯性更新到某个较新的版本,那么您的用户的原因是null
可能与以下事实有关:[email protected] /cdn-cgi/l/email-protection
the $page
返回一个完整的页面对象,而不仅仅是页面道具 - 所以在你的情况下,而不是$page.user
,你必须去$page.props.user
.
https://github.com/inertiajs/inertia/releases/tag/inertia-vue%40v0.3.0 https://github.com/inertiajs/inertia/releases/tag/inertia-vue%40v0.3.0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)