File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ declare type NavigationGuard = (
27
27
28
28
declare type AfterNavigationHook = ( to : Route , from : Route ) => any
29
29
30
+ type Position = { x : number , y : number } ;
31
+
30
32
declare type RouterOptions = {
31
33
routes ?: Array < RouteConfig > ;
32
34
mode ?: string ;
@@ -38,8 +40,8 @@ declare type RouterOptions = {
38
40
scrollBehavior ?: (
39
41
to : Route ,
40
42
from : Route ,
41
- savedPosition : ?{ x : number , y : number }
42
- ) => { x : number , y : number } | { selector : string } | ?{ } ;
43
+ savedPosition : ?Position
44
+ ) => Position | { selector : string , offset ?: Position } | ?{ } ;
43
45
}
44
46
45
47
declare type RedirectOption = RawLocation | ( ( to : Route ) => RawLocation )
Original file line number Diff line number Diff line change @@ -44,9 +44,12 @@ declare class VueRouter {
44
44
static install : PluginFunction < never > ;
45
45
}
46
46
47
+ type Position = { x : number , y : number } ;
48
+
47
49
export interface RouterOptions {
48
50
routes ?: RouteConfig [ ] ;
49
51
mode ?: RouterMode ;
52
+ fallback ?: boolean ;
50
53
base ?: string ;
51
54
linkActiveClass ?: string ;
52
55
linkExactActiveClass ?: string ;
@@ -55,8 +58,8 @@ export interface RouterOptions {
55
58
scrollBehavior ?: (
56
59
to : Route ,
57
60
from : Route ,
58
- savedPosition : { x : number , y : number } | undefined
59
- ) => { x : number , y : number } | { selector : string } | void ;
61
+ savedPosition : Position | void
62
+ ) => Position | { selector : string , offset ?: Position } | void ;
60
63
}
61
64
62
65
type RoutePropsFunction = ( route : Route ) => Object ;
Original file line number Diff line number Diff line change @@ -40,13 +40,18 @@ const Hook: ComponentOptions<Vue> = {
40
40
const router = new VueRouter ( {
41
41
mode : "history" ,
42
42
base : "/" ,
43
+ fallback : false ,
43
44
linkActiveClass : "active" ,
44
45
linkExactActiveClass : "exact-active" ,
45
46
scrollBehavior : ( to , from , savedPosition ) => {
46
47
if ( from . path === "/" ) {
47
48
return { selector : "#app" } ;
48
49
}
49
50
51
+ if ( from . path === "/offset" ) {
52
+ return { selector : '#foo' , offset : { x : 0 , y : 100 } }
53
+ }
54
+
50
55
if ( to . path === "/child" ) {
51
56
return ;
52
57
}
You can’t perform that action at this time.
0 commit comments