Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.v-link-active seems to be added to routes that match a given pattern, sometimes incorrect #114

Closed
jwalton512 opened this issue Sep 3, 2015 · 7 comments
Labels

Comments

@jwalton512
Copy link

I believe this is an issue, but could be incorrect. Given v-links with paths foo and foobar, when foobar is visited foo is still considered active.

https://jsbin.com/zukinud/edit?html,css,js,output

@yyx990803
Copy link
Member

Yeah, that's a bug.

@yyx990803 yyx990803 added the bug label Sep 3, 2015
@JosephSilber
Copy link

BTW, can the class name handling be abstracted into a separate directive?

I find myself wanting to highlight certain elements when a route is matched, but they're not links.

@yyx990803
Copy link
Member

@JosephSilber I'll keep that in mind, for now something like v-class="active: isActive('/a/b/c')" would probably work? (you need to implement isActive yourself)

@rrrhys
Copy link

rrrhys commented Nov 19, 2015

@JosephSilber

I found a workaround for this without custom code - attach v-link to the parent element too, and it will attach the active class without any hyperlink properties.

                <li v-link="{name: 'foo', activeClass: 'active'}">
                    <a v-link="{name: 'foo'}">Foo</a>
                </li>

Correctly attaches .active to <li>

@oguzhanaslan
Copy link

@rrrhys
This solutions, redirect to the homepage. Links are not working.
vue version: 0.12.16
vue-router version: 0.7.7

@jekinney
Copy link

jekinney commented Jun 7, 2016

Had the same issue until I added exact: true. Works great now

@altafhussain10
Copy link

Why do so much repeated work, just add a little css and change the li.active > a css to be applied on li > a.active. It works great with too much changes required repeatedly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants