javascript - Vue router-link exact active class -


i have 3 of menu tabs (i.e. router-links) correspond 3 different routes:

/        --> home /users   --> users /posts   --> posts 

the first router-link going / has exact property applied, not receive active class when on /users or /posts. works cases, planning on allowing query parameters on / route. example:

/?ref=producthunt 

in case, / router-link should still active. however, given have exact property on it, not matching url ref query parameter. outside of adding additional logic component test route , flip classes, there feature of router-link component can use solve this?

if want use router-link navigate '/' ref query parameter, why not set ref query property in router-link? still work exact.

<router-link :to="{ path: '/', query: { ref: 'producthunt' } }" exact>home</router-link> 

check demo here.

updated
if talking vue-router's setting issues, think url http://example.com/?ref=producthunt automatically directed home component without advanced configuration because there's no parameter exact in api (i tried in vuejs2+webpack project built vue-cli now). if wasn't directed home, wonder if there's wrong in other places server application's configuration.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -