NUXT JS动态参数嵌套页面

发布于 2025-02-02 06:25:04 字数 401 浏览 2 评论 0原文

我正在尝试为我的NUXT JS页面之一创建一个动态参数,并且正在努力找出正确的文件夹结构,我需要的URL将是:

其中123是我需要使用this。$ route的动态参数。

我已经尝试了以下文件夹标记:

  • 页/_ landing/index.vue
  • 页/landing/_index.vue

我该如何实现?

即使没有提供我的参数,我仍然需要加载页面

I'm trying to create a dynamic param for one of my nuxt JS pages and am struggling to figure out the correct folder structure, the URL I need will be something like:

Where 123 is my dynamic param that I need to grab using this.$route.

I've tried the following folder markups:

  • pages/_landing/index.vue
  • pages/landing/_index.vue

How can I achieve this?

I still need the page to load even if my param isn't supplied

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

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

评论(2

太阳男子 2025-02-09 06:25:04

使用[]语法

pages/landing/[paramName].vue

进一步阅读
https://v3.nuxtjs.s.s.org/guide/guide/guide/directory-schrenture/页面#动态路由

use the [ ] syntax

pages/landing/[paramName].vue

further read
https://v3.nuxtjs.org/guide/directory-structure/pages#dynamic-routes

忘你却要生生世世 2025-02-09 06:25:04

如果123是ID,则需要将文件保存为_id.vue,那么您可以使用this。$ oute.params.id

edit:您目录结构将为页面/登录/_id.vue

If 123 is the id, you need to save the file as _id.vue then you can get the value of id using this.$route.params.id

Edit: You directory structure will be pages/landing/_id.vue

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