Skip to content

Commit 598e979

Browse files
committed
feat: Expose $route to the watchers
1 parent eac80bc commit 598e979

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/router-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ export class RouterService {
283283
*/
284284
public setCurrentRoute(route: Route): void {
285285
this.currentRoute = route;
286+
287+
this.vm.$route = Object.assign(this.vm.$route, route);
286288
}
287289

288290
/**

src/vue-router.common.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export const createRouter = (
4141
proto.$routeTo = router.push.bind(router);
4242
proto.$routeBack = router.back.bind(router);
4343
proto.$router = router;
44+
45+
const route = (Vue as any).observable({
46+
name: '',
47+
path: '',
48+
});
49+
50+
proto.$route = route;
4451
}
4552

4653
if (vm.mixin) {

0 commit comments

Comments
 (0)