Skip to content

Instantly share code, notes, and snippets.

@AlanJenkinsVS
Created April 16, 2018 15:59
Show Gist options
  • Save AlanJenkinsVS/8af3a2b27eab5bec44f88d4d6a2c8fff to your computer and use it in GitHub Desktop.
Save AlanJenkinsVS/8af3a2b27eab5bec44f88d4d6a2c8fff to your computer and use it in GitHub Desktop.
6. Single Root Components - Vue JS Optimisations
<template>
<ul>
<NavBarRoutes :routes="persistentNavRoutes />
<NavBarRoutes
v-if="loggedIn"
:routes="loggedInNavRoutes" />
<NavBarRoutes
v-else
:routes="loggedOutNavRoutes" />
</ul>
</template>
<template>
<li
v-for="route in routes"
:key="route.name">
<router-link :to="route">
{{ route.title }}
</router-link>
</li>
</template>
<!-- Using a functional component with render we can return a multi-root component
<script>
export default {
functional: true,
render(h, { props }) {
<li key={route.name}>
<router-link to={route}>
{router.title}
</router-link>
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment