nuxtpage vs for nuxt33
这两个组件
在nuxt3
中有什么区别,我如何正确使用它们?
如果我想使用pages /... 在这里创建链接并从页面跳到页面的正确方法是什么?
What is the difference between these two components
in Nuxt3
and how do I use them correctly?
If I want to use pages/...
what is the right approach here to create links and jump from page to page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档中的所有内容几乎都在解释: https://v3.nuxtjs.org/迁移/页面和layouts/
您需要在
app.vue
中使用default
/layouts/default.vue.vue
文件,您将在上
/
(带有/pages/index.vue
)并且使用以下结构,您将获得动态页面
/pages/users/index.vue
/pages/users/[id] .vue
我在此处删除了布局以显示如何禁用它,但是您可以完全让默认值在这里,甚至提供自定义一个。
因此,
nuxt-page
要在要在应用中显示页面时使用(替换< nuxt/>
and code> and< nuxt; nuxt; nuxt; nuxt; />
)时< slot/>
将用于布局(作为使用插槽
tag )。Everything is pretty much explained in the documentation: https://v3.nuxtjs.org/migration/pages-and-layouts/
You need to use this in
app.vue
With a default
/layouts/default.vue
fileYou will get this on
/
(with/pages/index.vue
)And with the following structure, you will achieve dynamic pages
/pages/users/index.vue
/pages/users/[id].vue
I've removed the layout here to show how to disable it, but you can totally let the default here or even provide a custom one.
So,
nuxt-page
is to be used when you want to display the pages in your app (replacing<nuxt />
and<nuxt-child />
) while<slot />
is to be used in the layout (as any other component using theslot
tag).