M
M
myskypesla2017-04-19 16:17:27
Vue.js
myskypesla, 2017-04-19 16:17:27

Why is there a problem with router-link-active?

I am initializing the project with vue init webpack my-project .
I make a horizontal menu and write in it:

<router-link to="/"></router-link>
<router-link to="/about"></router-link>
<router-link to="/team"></router-link>
<router-link to="/contacts"></router-link>

And I want to highlight the active menu item with an underline, but when switching between routes, the new item on which I clicked becomes active, and the very first one also remains active, i.e. 2 menu items still have class="router-link-active".
Has anyone come across? How to decide?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem0071, 2017-04-19
@myskypesla

In the first one in the tag after to="/" write exact
All your items contain "/", so the first one is highlighted along with the rest

E
Evgeny Kulakov, 2017-04-19
@kulakoff Vue.js

You can just IMHO remove the slash for the first route.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question