My folder structure is like this:
|-profile
|-- index.vue
|-- address/index.vue
And then I do <nuxt-child />
which doesn't render the content of profile/index.vue
! It just loads a whole new route. Please help!
How to use the Nuxt Child component to create parent and child pages. pages/parent.vue contains the <NuxtChild> component. Everything on this page will be seen on both the parent and child pages. pages/parent/index.vue contains text that will be replaced when the child links are clicked.
This component is used for displaying the children components in a nested route. To display the child.vue component, we have to insert <nuxt-child/> inside pages/parent.vue: Child components can also receive properties like a regular Vue component. To see an example, take a look at the nested-routes example.
To display the child.vue component, we have to insert <nuxt-child/> inside pages/parent.vue: Child components can also receive properties like a regular Vue component. To see an example, take a look at the nested-routes example.
When using keep-alive on <nuxt-child/>, the children components will register two additional lifecycle hooks: activated and deactivated . These hooks are called on the client side when entering and leaving the child component. To see an example, take a look at the named-views example.
Folder structure above will create a whole new route, instead of a nested one.
You can see exact same structure in Nuxt.js Routing documentation example.
Examples of nested routes are also available in documentation
In your case, in order to render nested route in <nuxt-child>
, following structure will work:
|-pages/
|--| profile/
|-----| address.vue
|-----| index.vue
|--| profile.vue
And <nuxt-child>
tag should be inside profile.vue
page. This way profile/index.vue
will be rendered when user navigates to /profile
and address.vue
will be rendered when user navigates to /profile/address
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With