我在laravel 8中使用了惯性js和react,同时显示了我的单页博客和路由,它显示了上面的错误。
在我的路线上
Route::get('blogs/{blog:slug}', [BlogController::class, 'show'])->name('blogs.show');
在我的控制器中
public function show(Blog $blog)
{
return inertia('Blogs/Show', compact('blog'));
}
在我看来
<Link href={route('blogs.show', props.blog.slug)} className="text-blue-500 inline-flex items-center md:mb-2 lg:mb-0">Learn More
<svg className="w-4 h-4 ml-2" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2" fill="none" strokeLinecap="round" strokeLinejoin="round">
<path d="M5 12h14"/>
<path d="M12 5l7 7-7 7"/>
</svg>
</Link>
发布于 2021-12-01 02:53:24
首先运行php artisan route:list
以确保您的路由中没有额外的参数。
即使这样,这段代码也应该按照文档指定的方式工作。我建议指定参数以确保它在那里,并且不会丢失另一个参数。
route('blogs.show', {slug: props.blog.slug})
https://stackoverflow.com/questions/70164519
复制相似问题