可以使用子目录重写URL
我的项目结构默认
- pages
- login.vue
- index.vue
auth
- about.vue
情况下,NUXT可以使用'localhost:3000/'访问路径,并且它将由/pages/index.vue渲染。
如果我想访问dir auth中的页面,则必须是访问路径 'local主持:3000/auth/关于
但是我想通过'localhost:3000/about
访问路径
I have project structure like this
- pages
- login.vue
- index.vue
auth
- about.vue
by default, nuxt can access a path with 'localhost:3000/' and it will rendered by /pages/index.vue
in case if i want to access a page in dir auth/about it's must be access a path
'localhost:3000/auth/about'
but i want to access path with 'localhost:3000/about
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用页面别名点
使以下文件结构
可以通过
/about
或/auth/aid about
访问。You can use a page alias if you want to have another entry point
So that the following file structure
could be accessed via either
/about
or/auth/about
.在NUXT 3.13和NUXT 4中,您可以使用页面分组:
In Nuxt 3.13 and Nuxt 4, you can use page grouping: