[英]Stop nuxt from looking in folders in specific scope
I have a url called eg: https://example.com/category/laptop/keyboard .我有一个网址,例如: https://example.com/category/laptop/keyboard 。
Normal behaviour is that nuxt automatically looks inside /pages
for a "category" folder (which is fine) and then further more: "laptop" folder and last "keyboard" folder in which should contain a vue file.正常行为是 nuxt 会自动在/pages
查找“类别”文件夹(这很好),然后进一步查找:“笔记本电脑”文件夹和最后一个“键盘”文件夹,其中应包含一个 vue 文件。
I would like that "laptop/keyboard" is referred to a :slug
param instead of folder traverse but only in the scope of /category/
.我希望“笔记本电脑/键盘”被称为:slug
参数而不是文件夹遍历,但仅在/category/
的范围内。 Is that possible?那可能吗? It's because of sub-nested categories.这是因为子嵌套类别。
I have tried to add a custom route example:我试图添加一个自定义路由示例:
router: {
extendRoutes(routes, resolve) {
routes.push({
name: 'custom',
path: '/product-category/*',
component: resolve(__dirname, 'pages/produkt-kategori/_category')
})
}
},
Unfortunately this does not work, it's just reverting to 404. Furthermore I can't get the params with that.不幸的是,这不起作用,它只是恢复到 404。此外,我无法获得参数。
So.所以。 Found out that I needed to use "Unknown Dynamic Nested Routes", referring to this documentation: https://nuxtjs.org/docs/2.x/features/file-system-routing .发现我需要使用“未知动态嵌套路由”,参考这个文档: https : //nuxtjs.org/docs/2.x/features/file-system-routing 。
Just create a _.vue
file in a sub-folder, then everything after a scope will become dynamic, also nested.只需在子文件夹中创建一个_.vue
文件,那么作用域之后的所有内容都将变为动态的,也是嵌套的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.