在Nuxt.js中,我创建了以下文件夹结构:
âââ parent â  âââ child1.vue â  âââ child2.vue âââ parent.vue
在 父.vue ,我有这个:
<template> <div> <h3>Parent element</h3> <ul> <li><nuxt-child/></li> <li><nuxt-child/></li> </ul> </div> </template>
在 儿童1.vue
<template> <div> <h3>Child 1</h3> </div> </template>
在 儿童2.vue
<template> <div> <h3>Child 2</h3> </div> </template>
我启动服务器(运行dev)并执行以下URI: http://localohost:3000/parent
http://localohost:3000/parent
Parent element - -
如果我去 http://localohost:3000/parent/child1 ,我看到这个:
http://localohost:3000/parent/child1
Parent element - Child 1 - Child 1
如果我去 http://localohost:3000/parent/child2 ,我看到这个:
http://localohost:3000/parent/child2
Parent element - Child 2 - Child 2
问题:
从 documentation ,我明白 儿童1.vue 儿童2.vue 是parent.vue的孩子,所以我希望在访问时看到他们的列表 http://localhost:3000/parent ,但它们没有显示。每个子级仅在指向其URI时显示。有人能解释我的这种行为吗?
http://localhost:3000/parent
<nuxt-child/> 是子组件的替代品, 基于 .
<nuxt-child/>
<template> <div> <h3>Parent element</h3> <nuxt-child/> </div> </template>
然后把你需要的东西放在孩子身上。
nested routes .
例如,假设我有一些事件。父页是 event ,则每个事件都是一个子事件。
event
- events - christmas - easter
当我去 events/christmas events/easter ,我将看到活动页面,但其中包含我想要的活动内容。父页 events/
events/christmas
events/easter
events/