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

Different route define, but the same suffix path, will all be actived! #1091

Closed
muei opened this issue Jan 11, 2017 · 6 comments
Closed

Different route define, but the same suffix path, will all be actived! #1091

muei opened this issue Jan 11, 2017 · 6 comments
Labels

Comments

@muei
Copy link

muei commented Jan 11, 2017

vue-router's version: 3.10.9

// routes.js
const routes = [
   {name: 'tag', path:'tag'},
   {name: 'tagtype', path:'tagtype'}
]

// pug's template
ul
   li(v-for="item in items")
      router-link(active-class="active" v-bind:to="item.to") 

// data
[
  {title: 'tagtype',  to: {name: 'tagtype'}},
  {title: 'tag', to: {name: 'tag'}},
]

The url path /tag '/tagype' will all be actived!
If change tagtype with a different suffix, like atagtype, this bug will be fixed!

@posva
Copy link
Member

posva commented Jan 11, 2017

This is expected, you're looking for the exact prop on router-link: https://router.vuejs.org/en/api/router-link.html#exact

@posva posva closed this as completed Jan 11, 2017
@muei
Copy link
Author

muei commented Jan 11, 2017

Not the same!
/tag with /tag/other will all be actived, if not set exact = true, that's right! But
like /tagxxx/ will be actived too, it's not very suitable.
And also I set the exact=true, they(/tag /tagxxx) will be all actived too! So I think this is a bug! Please check it.
You can see the demo, the path /usersa: https://jsfiddle.net/8xrk1n9f/28/

@posva
Copy link
Member

posva commented Jan 11, 2017

it's not a bug, please, read the docs I sent you:

The default active class matching behavior is inclusive match. For example, will get this class applied as long as the current path starts with /a.

@muei
Copy link
Author

muei commented Jan 11, 2017

I'v readed it, ok. I hope '/a' not match '/axxx', can match '/a/xxx/xxx'. @yyx990803

@yyx990803 yyx990803 reopened this Jan 17, 2017
@yyx990803
Copy link
Member

Yeah, /usera should not make /user links highlighted.

@yyx990803 yyx990803 added the bug label Jan 17, 2017
@lukepolo
Copy link

I just ran across this issue as well

http://codepier.dev:3000/site/1/
http://codepier.dev:3000/site/14/

Both are marked as active links

posva added a commit that referenced this issue Jan 17, 2017
Fix #1091
Fix the doc too
yyx990803 pushed a commit that referenced this issue Jan 18, 2017
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

4 participants