Vue JS Set active-class on Route

<router-link tag="li" :to="..." :class="{ 'router-link-active': isProjectTypeRoute }">
  <a>Project</a>
</router-link>
computed: {
  isProjectTypeRoute() { 
    return this.$route.matched.some(route => route.name === 'project')
  }
}
Facebook Comments

You may also like