[Vuejs]-Vue Router duplicate $route info

0👍

There are multiple route parts that are matched for a given URL when nested routes are involved. You’ll need to search this.$route.matched for the specific route that you are interested in.

If you set a name for the route you’re interested in, it’ll make it easier to find:

{
  path: 'editor',
  name: 'editor',  // <-- Add this
  component: EditorView,
  meta: {
    title: 'User Editor'
  }
}
mounted() {
  const route = this.$route.matched.find(r => r.name === 'editor');
  console.log(route.meta.title);
}

Leave a comment