[英]Laravel Inertia Ziggy Link Routing Issue
I'm currently having a problem in my routing.我目前在路由中遇到问题。 Here's the scenario:
这是场景:
Inertia is working fine when there's no id query.当没有 id 查询时,惯性工作正常。
But after navigating to edit and I want to click any of the navigation links like clicking the Dashboard link, it throws a 404 code saying the page does not exist.但是在导航到编辑并且我想单击任何导航链接(例如单击仪表板链接)后,它会抛出一个 404 代码,说明该页面不存在。 Simply because instead of removing the /category/{id}, it adds dashboard at the end instead of removing the query.
仅仅是因为它没有删除 /category/{id},而是在末尾添加仪表板而不是删除查询。
Is there a way to fix this by not violating the inertia routing?有没有办法通过不违反惯性路由来解决这个问题?
Here's the code:这是代码:
Authenticated Layout认证布局
const navigation = [
{ name: 'Dashboard', href: 'dashboard', current: false },
{ name: 'Category', href: 'category', current: false },
]
<nav class="hidden lg:flex lg:space-x-8 lg:py-2" aria-label="Global">
<Link v-for="item in navigation" :key="item.name"
:href="item.href" :class="[item.current ? 'bg-gray-100
text-gray-900' : 'text-gray-900 hover:bg-gray-50
hover:text-gray-900', 'rounded-md py-2 px-3 inline-flex
items-center text-sm font-medium']" :aria-
current="item.current ? 'page' : undefined">{{ item.name
}}</Link>
</nav>
Solved it.解决了。 Just needed to add "/" to the href navigation object.
只需在 href 导航 object 中添加“/”即可。
const navigation = [
{ name: 'Dashboard', href: '/dashboard', current: false },
{ name: 'Category', href: '/category', current: false },
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.