简体   繁体   English

如何在nuxt中简化深度嵌套路由

[英]How to simple deep nested route in nuxt

I have a trouble routing with nuxt .我在使用nuxt路由时nuxt

For example I have url like this www.example.com/slug1/slug2/slug3/slug4 .例如,我有这样的url www.example.com/slug1/slug2/slug3/slug4

On basic nuxt routing, it should be like this in the folder:在基本的nuxt路由上,文件夹中应该是这样的:

pages //main page
  _slug1 //folder fol slug1
   index.vue //index for slug1
   _slug2 //folder for slug2
    index.vue //index for slug2
    _slug3 //folder for slug3
     index.vue //index for slug3
     _slug4 //folder for slug4
      index.vue //index for slug4

Is there a simple way?有没有简单的方法? For example just 1 folder for all that routes?例如,所有路线只有 1 个文件夹?

pages
  _slug //folder for all slug (slug1, slug2, slug3 and slug4)

Hello you can use theUnknown dynamic nested routes feature to achieve that.您好,您可以使用未知动态嵌套路由功能来实现这一点。 Basically, add a pages/_.vue file and fetch the correct content based on the path.基本上,添加一个pages/_.vue文件并根据路径获取正确的内容。

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

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