vuejs <router-link> component keeps the link to the root path always active vuejs <router-link> component keeps the link to the root path always active vue.js vue.js

vuejs <router-link> component keeps the link to the root path always active


The root link is always active, because Vue Router partially matches the root / path with the current path.

To perform an exact match you can either:

  1. Add an exact attribute to the router-link:

    <router-link tag="li" to="/" exact>    <a href="#">        Home    </a></router-link>
  2. Set your active class in the linkExactActiveClass router constructor option instead of linkActiveClass.