I am building a Vue 3 frontend and am using Vue Router 4 for navigation. I want to build a generic navigation based on the router definition. I want to use the current route and show links to the children of the route, but I see no children.
Here is what I do in my component:
<script setup>
import { useRoute } from 'vue-router';
import { onMounted } from 'vue';
const route = useRoute();
onMounted(async () => {
console.error('route.children', route.children); // Shows undefined
});
</script>
Here is my route definition:
{
path: '/users',
name: 'users',
component: usersComponent,
meta: {
title: 'Users'
},
children: [
{
path: 'images',
name: 'userImages',
component: imageComponent,
meta: {
title: 'Images'
}
},
{
path: 'profile',
name: 'useProfile',
component: profileComponent,
meta: {
title: 'Profile'
}
}
],
}