Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Router

Svelte Router core class.

Hierarchy

  • Router

Index

Constructors

constructor

Accessors

activeClass

  • get activeClass(): string
  • Get router link active class

    Returns string

basename

  • get basename(): string

currentRoute

  • get currentRoute(): Route | null

mode

routes

Methods

back

  • back(): void
  • Go one step back in the navigation history.

    Returns void

forward

  • forward(): void
  • Go one step forward in the navigation history.

    Returns void

go

  • go(n: number): void
  • Go to a specific history position in the navigation history.

    Parameters

    • n: number

      number of steps to forward or backwards (negative number).

    Returns void

navigationGuard

  • Register a navigation guard which will be called whenever a navigation is triggered. All registered navigation guards are resolved in sequence. Navigation guard must call the next() function to continue the execution of navigation change.

    Parameters

    Returns function

    Unregister guard function.

      • (): void
      • Returns void

onBeforeNavigation

  • Register a callback which will be called before execution of navigation guards.

    Parameters

    Returns function

    Unregister listener function.

      • (): void
      • Returns void

onError

  • Register a callback which will be called when an error is caught during a route navigation.

    Parameters

    Returns function

    Unregister callback function.

      • (): void
      • Returns void

onNavigationChanged

  • Register a callback which will be called when all navigation guards are resolved, and the final navigation change is resolved.

    Parameters

    Returns function

    Unregister listener function.

      • (): void
      • Returns void

push

  • push(rawLocation: RawLocation | string, onComplete?: undefined | function, onAbort?: undefined | function): void
  • Push to navigation.

    throws

    When the rawLocation is invalid or when the path is invalid.

    Parameters

    • rawLocation: RawLocation | string

      raw path or location object.

    • Optional onComplete: undefined | function

      On complete callback function.

    • Optional onAbort: undefined | function

      On abort callback function.

    Returns void

replace

  • replace(rawLocation: RawLocation | string, onComplete?: undefined | function, onAbort?: undefined | function): void
  • Replace in navigation

    throws

    when the rawLocation is invalid or when the path is invalid.

    Parameters

    • rawLocation: RawLocation | string

      raw path or location object.

    • Optional onComplete: undefined | function

      On complete callback function.

    • Optional onAbort: undefined | function

      On abort callback function.

    Returns void

routeURL

  • Generate route URL from the the raw location.

    throws

    when the route is not found or the route params are not valid.

    Parameters

    Returns string

start

  • start(): void
  • Trigger the on load history change.

    Returns void

Generated using TypeDoc