NUXT JS动态参数嵌套页面
我正在尝试为我的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用[]语法
进一步阅读
https://v3.nuxtjs.s.s.org/guide/guide/guide/directory-schrenture/页面#动态路由
use the [ ] syntax
further read
https://v3.nuxtjs.org/guide/directory-structure/pages#dynamic-routes
如果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 usingthis.$route.params.id
Edit: You directory structure will be
pages/landing/_id.vue