Skip to content

Commit 03bdc38

Browse files
committed
expose router on $route
1 parent 4cb563a commit 03bdc38

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/directives/link.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function (Vue) {
2020
)
2121
return
2222
}
23-
let router = vm.$route._router
23+
let router = vm.$route.router
2424
this.handler = (e) => {
2525
if (e.button === 0) {
2626
e.preventDefault()
@@ -43,7 +43,7 @@ export default function (Vue) {
4343
updateClasses: function (path) {
4444
let el = this.el
4545
let dest = this.destination
46-
let router = this.vm.$route._router
46+
let router = this.vm.$route.router
4747
let activeClass = router._linkActiveClass
4848
let exactClass = activeClass + '-exact'
4949
if (path.indexOf(dest) === 0 && path !== '/') {
@@ -62,7 +62,7 @@ export default function (Vue) {
6262
this.destination = path
6363
this.updateClasses(this.vm.$route.path)
6464
path = path || ''
65-
let router = this.vm.$route._router
65+
let router = this.vm.$route.router
6666
let isAbsolute = path.charAt(0) === '/'
6767
// do not format non-hash relative paths
6868
let href = router.mode === 'hash' || isAbsolute

src/directives/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function (Vue) {
3737
// all we need to do here is registering this view
3838
// in the router. actual component switching will be
3939
// managed by the pipeline.
40-
let router = this.router = route._router
40+
let router = this.router = route.router
4141
router._views.unshift(this)
4242

4343
// note the views are in reverse order.

src/override.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function (Vue) {
88
Vue.prototype.$addChild = function (opts, Ctor) {
99

1010
let route = this.$route
11-
let router = route && route._router
11+
let router = route && route.router
1212

1313
// inject meta
1414
if (router) {

src/route.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default class Route {
99

1010
constructor (path, router) {
1111
this.path = path
12+
this.router = router
13+
1214
let matched = router._recognizer.recognize(path)
1315

1416
this.query = matched
@@ -27,15 +29,6 @@ export default class Route {
2729
: {}
2830

2931
// private stuff
30-
this._aborted = false
31-
def(this, '_matched', matched || router._notFoundHandler)
32-
def(this, '_router', router)
32+
this._matched = matched || router._notFoundHandler
3333
}
3434
}
35-
36-
function def (obj, key, val) {
37-
Object.defineProperty(obj, key, {
38-
value: val,
39-
enumerable: false
40-
})
41-
}

0 commit comments

Comments
 (0)