Javascript Nuxt.js:理解<;nuxt child>;成分
在Nuxt.js中,我创建了以下文件夹结构:Javascript Nuxt.js:理解<;nuxt child>;成分,javascript,vue.js,nuxt.js,Javascript,Vue.js,Nuxt.js,在Nuxt.js中,我创建了以下文件夹结构: ├── parent │ ├── child1.vue │ └── child2.vue ├── parent.vue 在parent.vue中,我有以下内容: <template> <div> <h3>Parent element</h3> <ul> <li><nuxt-child/><
├── parent
│ ├── child1.vue
│ └── child2.vue
├── parent.vue
在parent.vue中,我有以下内容:
<template>
<div>
<h3>Parent element</h3>
<ul>
<li><nuxt-child/></li>
<li><nuxt-child/></li>
</ul>
</div>
</template>
如果我转到http://localohost:3000/parent/child1
,我看到了这一点:
Parent element
-
-
Parent element
- Child 1
- Child 1
Parent element
- Child 2
- Child 2
如果我转到http://localohost:3000/parent/child2
,我看到了这一点:
Parent element
-
-
Parent element
- Child 1
- Child 1
Parent element
- Child 2
- Child 2
问题:
从中,我了解到child1.vue和child2.vue是parent.vue的孩子,因此我希望在访问http://localhost:3000/parent
,但它们没有显示。仅当我指向其URI时,才会显示每个子级。有人能解释我这种行为吗?基于路线,是子组件的替代品
您只需要使用一个:
<template>
<div>
<h3>Parent element</h3>
<nuxt-child/>
</div>
</template>
当我进入events/christmas
或events/easter
时,我会看到“event”页面,但其中包含我想要的活动内容。家长页面events/
可能只包含我要访问的所有事件的列表。我知道你所说的一切,我希望你能根据路线详细说明,因为我觉得真正的解释就在附近。非常感谢。