简体   繁体   English

Nuxt路由:找不到子页面

[英]Nuxt Routing: Child Pages not found

I am building a Nuxt app that uses the WordPress REST API for content. 我正在构建一个使用WordPress REST API的内容的Nuxt应用程序。 All my other routes work fine, but I'm coming unstuck when it comes to nested pages. 我的所有其他路由都工作正常,但涉及嵌套页面时,我会陷入困境。

I'm using the following structure in my Nuxt app: 我在Nuxt应用程序中使用以下结构:

pages 页数
--- _slug --- _sl
------ index.vue ------ index.vue

In WordPress, an example would be: 在WordPress中,示例如下:

How To Get There (slug: how-to-get-there) 如何到达那里(sl:怎么去那里)
-- Roads & Road Safety (slug: roads-road-safety) -道路与道路安全(条款:道路与道路安全)

I must be misunderstanding how routing works as this doesn't work and I get a 404 error when attempting to access the child page. 我一定会误解路由的工作方式,因为这行不通,并且在尝试访问子页面时收到404错误。

What is the correct way to route a child page from WordPress? 从WordPress路由子页面的正确方法是什么?

I read this from guideline of Nuxt. 我从Nuxt指南中阅读了此内容。

"To define a dynamic route with a parameter, you need to define a .vue file OR a directory prefixed by an underscore." “要使用参数定义动态路由,需要定义.vue文件或带下划线前缀的目录。”

So it should be 所以应该

pages/ 
--| _slug/ 
-----| _slug.vue

Ref: Routing in Nuxt 参考: 在Nuxt中路由

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM