File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { HashHistory } from './history/hash'
2
2
import { HTML5History } from './history/html5'
3
3
import { supportsPushState } from '../util/env'
4
+ import * as dom from '../util/dom'
4
5
5
6
export function routerMixin ( proto ) {
6
7
proto . route = { }
7
8
}
8
9
9
10
let lastRoute = { }
10
11
12
+ function updateRender ( vm ) {
13
+ vm . router . normalize ( )
14
+ vm . route = vm . router . parse ( )
15
+ dom . body . setAttribute ( 'data-page' , vm . route . file )
16
+ }
17
+
11
18
export function initRouter ( vm ) {
12
19
const config = vm . config
13
20
const mode = config . routerMode || 'hash'
@@ -20,13 +27,11 @@ export function initRouter (vm) {
20
27
}
21
28
22
29
vm . router = router
23
-
24
- router . normalize ( )
25
- lastRoute = vm . route = router . parse ( )
30
+ updateRender ( vm )
31
+ lastRoute = vm . route
26
32
27
33
router . onchange ( _ => {
28
- router . normalize ( )
29
- vm . route = router . parse ( )
34
+ updateRender ( vm )
30
35
vm . _updateRender ( )
31
36
32
37
if ( lastRoute . path === vm . route . path ) {
You can’t perform that action at this time.
0 commit comments