NUXT 3路由:“简单”动态路线返回404错误
我正在尝试使用NUXT3(“ 3.0.0-rc.3”)进行简单的动态链接,并且无法达到动态slug url。我遵循此页面,但似乎对我不起作用: https://nuxtjs.org/examples/routing/dynamic-pages
这是我的简单的页面结构:
pages/
index.vue
category/
_id.vue
当我尝试到达我的localhost:3000/category/test
时,我的404错误页面带有消息“找不到页面:/category/test”。
这是我的“ index.vue”文件中的链接:
<NuxtLink to="/category/test">Test</NuxtLink>
这是我的“ _id.vue”文件的内容:
<template>
<div>
<h1>Project: {{ $route }}</h1>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
I'm trying to make a simple dynamic link with nuxt3 ("3.0.0-rc.3") and I cannot reach dynamic slug url. I followed this page but it doesn't seem to work for me :
https://nuxtjs.org/examples/routing/dynamic-pages
Here is my simple page structure :
pages/
index.vue
category/
_id.vue
When I try to reach my localhost:3000/category/test
I have the 404 error page with the message "Page not found: /category/test".
Here is the link in my "index.vue" file :
<NuxtLink to="/category/test">Test</NuxtLink>
Here is the content of my "_id.vue" file :
<template>
<div>
<h1>Project: {{ $route }}</h1>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在NUXT 3中,动态路由的写入就像
[ID]
,而不是_id
:有关更多详细信息,请检查此 https://v3.nuxtjs.org/guide/directory-scrupture/pages#dynamic-routes
In Nuxt 3 the dynamic routes are written like
[id]
instead of_id
:for more details check this https://v3.nuxtjs.org/guide/directory-structure/pages#dynamic-routes