[Vuejs]-Vuejs create dynamically a Nav List Item from Route Children Paths

0๐Ÿ‘

I think you are looking for this:

computed: {
    routeList() {
        return this.$router.options.routes
    }
}

0๐Ÿ‘

Got it, I added all Layout Stuff into my App.vue and uses the routes like normal, why so complicated ๐Ÿ™‚

    const routes = [

  { path: '/', name: 'home', component: () => import('pages/Index.vue') },
  { path: '/users', name: 'users', component: () => import('pages/Users.vue') },
  { path: '/news', name: 'news', component: () => import('pages/News.vue') },
  { path: '*', component: () => import('pages/Error404.vue') },

];

export default routes;

and as nav links:

  <router-link
      v-for="route in $router.options.routes"
      :key="route.path"
      :to="route.path"
      >{{ route.name }}</router-link
    >

works as aspected.

Leave a comment