javascript - Vue router-link exact active class -
i have 3 of menu tabs (i.e. router-link
s) 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
Post a Comment