vue.js - Nuxt 路由器,比 nuxt-child 更深入
问题描述
我正在使用 Nuxt Child 组件,但也想更深地链接到孩子。
我认为这最能说明问题。
example.com/cars <-- cars.vue (has nuxt-child)
example.com/cars/bmw/ <-- cars/_maker.vue (this is the child)
example.com/cars/ford/ <-- cars/_maker.vue (this is the child)
example.com/cars/bmw/i3 <-- cars/_maker/type.vue (shows wrong template)
example.com/cars/ford/mustang <-- cars/_maker/type.vue (shows wrong template)
_type.vue
不渲染,而是使用_maker.vue
模板。
我没有扩展路由设置,它完全脱离了目录结构路由。
如何获取使用模板/i3
的/mustang
路径?type.vue
我想我可以通过不使用 Nuxt-Child 并做类似的事情来做到这一点,但我失去了良好的 Nuxt-Child 行为。
example.com/cars <-- cars/index.vue
example.com/cars/bmw/ <-- cars/_maker/index.vue
example.com/cars/bmw/i3 <-- cars/_maker/_type.vue
解决方案
尝试在pages
这样的文件夹上设置结构。
pages/
--| _cars/
-----| _maker/
--------| _type.vue
--------| index.vue
-----| _maker.vue
-----| index.vue
--| _cars.vue
--| index.vue
只需添加<nuxt-child/>
in _cars.vue
,如果不需要,则_maker.vue
删除_type.vue
文件。index.vue
.
推荐阅读
- php - 在php中获取要检查的复选框
- java - 如何使用 JPA 将数据库中的表和记录传输到类和对象?
- google-cloud-platform - Gcloud 无法获取资源:指定的 IP 地址未分配给项目或不属于指定范围
- jquery - Add second child of li element in existing ul
- c# - How to select and return a word from an enum
- powershell - PowerShell Sort-Object -top -bottom -stable 排序
- javascript - Meteor remove function doesn't work on a Collection
- python - I want to use the parameter passed in function as variable
- r - How to convert list of lists to dataframe in R
- angularjs - 使用角度将多个输入传递给我的过滤器