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 = (
2727
2828declare type AfterNavigationHook = ( to : Route , from : Route ) => any
2929
30+ type Position = { x : number , y : number } ;
31+
3032declare type RouterOptions = {
3133 routes ?: Array < RouteConfig > ;
3234 mode ?: string ;
@@ -38,8 +40,8 @@ declare type RouterOptions = {
3840 scrollBehavior ?: (
3941 to : Route ,
4042 from : Route ,
41- savedPosition : ?{ x : number , y : number }
42- ) => { x : number , y : number } | { selector : string } | ?{ } ;
43+ savedPosition : ?Position
44+ ) => Position | { selector : string , offset ?: Position } | ?{ } ;
4345}
4446
4547declare type RedirectOption = RawLocation | ( ( to : Route ) => RawLocation )
Original file line number Diff line number Diff line change @@ -44,9 +44,12 @@ declare class VueRouter {
4444 static install : PluginFunction < never > ;
4545}
4646
47+ type Position = { x : number , y : number } ;
48+
4749export interface RouterOptions {
4850 routes ?: RouteConfig [ ] ;
4951 mode ?: RouterMode ;
52+ fallback ?: boolean ;
5053 base ?: string ;
5154 linkActiveClass ?: string ;
5255 linkExactActiveClass ?: string ;
@@ -55,8 +58,8 @@ export interface RouterOptions {
5558 scrollBehavior ?: (
5659 to : Route ,
5760 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 ;
6063}
6164
6265type RoutePropsFunction = ( route : Route ) => Object ;
Original file line number Diff line number Diff line change @@ -40,13 +40,18 @@ const Hook: ComponentOptions<Vue> = {
4040const router = new VueRouter ( {
4141 mode : "history" ,
4242 base : "/" ,
43+ fallback : false ,
4344 linkActiveClass : "active" ,
4445 linkExactActiveClass : "exact-active" ,
4546 scrollBehavior : ( to , from , savedPosition ) => {
4647 if ( from . path === "/" ) {
4748 return { selector : "#app" } ;
4849 }
4950
51+ if ( from . path === "/offset" ) {
52+ return { selector : '#foo' , offset : { x : 0 , y : 100 } }
53+ }
54+
5055 if ( to . path === "/child" ) {
5156 return ;
5257 }
You can’t perform that action at this time.
0 commit comments