[Vuejs]-V-link add linkActiveClass ,how to match routerName or (path and query)?

0πŸ‘

In this case I see two solutions

  1. along with routerName you also need to compare query params which can be accessed by: this.$route.query. accountType
  2. You can compare $route.fullPath which includes URL including query and hash.

But I am not sure why you have these two routes different: ideally these should be ideally same route with different query Param. Also have a look at this answer.

0πŸ‘

Per docs: https://router.vuejs.org/en/api/router-link.html

I would suggest to use:

  <!-- with query, resulting in /register?plan=private -->
  <router-link :to="{ path: 'accountType', query: { accountType: '1' }}"></router-link>
<router-link :to="{ path: 'accountType', query: { accountType: '2' }}"></router-link>

Leave a comment