NUXT 3路由:“简单”动态路线返回404错误

发布于 2025-01-31 12:37:39 字数 794 浏览 0 评论 0原文

我正在尝试使用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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟沫凡尘 2025-02-07 12:37:39

在NUXT 3中,动态路由的写入就像[ID],而不是_id

pages/
   index.vue
   category/
       [id].vue

有关更多详细信息,请检查此 https://v3.nuxtjs.org/guide/directory-scrupture/pages#dynamic-routes

In Nuxt 3 the dynamic routes are written like [id] instead of _id :

pages/
   index.vue
   category/
       [id].vue

for more details check this https://v3.nuxtjs.org/guide/directory-structure/pages#dynamic-routes

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文