Skip to content

Commit 3bb4527

Browse files
committed
fix active class matching (follow up #209)
1 parent 029a0f7 commit 3bb4527

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/directives/link.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { warn } from '../util'
22
const trailingSlashRE = /\/$/
33
const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g
4+
const queryStringRE = /\?.*$/
45

56
// install v-link, which provides navigation support for
67
// HTML5 history mode
@@ -110,15 +111,15 @@ export default function (Vue) {
110111

111112
updateClasses (path) {
112113
let el = this.el
113-
let dest = this.path
114114
let router = this.vm.$route.router
115115
let activeClass = this.activeClass || router._linkActiveClass
116116
// clear old class
117117
if (this.prevActiveClass !== activeClass) {
118118
_.removeClass(el, this.prevActiveClass)
119119
}
120120
// remove query string before matching
121-
path = path.replace(/\?.*$/, '')
121+
let dest = this.path.replace(queryStringRE, '')
122+
path = path.replace(queryStringRE, '')
122123
// add new class
123124
if (this.exact) {
124125
if (

0 commit comments

Comments
 (0)