Static GitHub Issues

[1234] nuxt shouldnt generate children routes for wildcard routes

prev: loading order for plugins, dependent on other plugins
next: I have to run under the dev in the build after the start can not open the page without any tips - 萌新 菜鸟问个弱鸡问题 我在dev下 都运行的好好的 在build后 start 打不开网页 也没任何提示

what do you want to do

I would like to have the following urls:

/category1/subcategory2/.../subcategoryx
/product_name/p/product_id

So there is no 'type' identifier at the start of the url, which means you need to trick vue-router a bit in using the correct component. Here I use the /p/ part in the product url to identify between categories and products. (Even better would be if you could identify by 'product_id = integer' and 'subcategory = string' but afaik this is not possible with vue-router)

what did you do

In my pages folder I have the following structure:

pages
├── _.vue // component for category pages
└── _/
   └── p/
       └── _.vue // component for product pages

what did you expect to happen

The correct configuration for vue-router should be as follows. Also see this jsfiddle: https://jsfiddle.net/50wL7mdz/50616/

[{
   path: '/*/p/*',
   name: 'all-p',
   component: products
},{
   path: '/*',
   name: 'all',
   component: categories,
 }]

what happened actually

nuxt generates the above routes with children routes:

{
   path: '/*',
   name: 'all',
   component: categories,
   children: {
      path: 'p',
      name: 'all-p',
      component: products
   }
 }

But as both routes will contain a *, the routes should be added in ascending greediness (with '/*' being most greedy). By using a children structure you loose the ability to list routes based on their greediness. It seems Nuxt.js already does this correctly when you use :slug's, but not when you use wildcards.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1088">#c1088</a>)</em></sub></div>