Router Construction Options
routes
type:
Array<RouteConfig>Type declaration for
RouteConfig:declare type RouteConfig = { path: string; component?: Component; name?: string; // for named routes components?: { [name: string]: Component }; // for named views redirect?: string | Location | Function; props?: boolean | string | Function; alias?: string | Array<string>; children?: Array<RouteConfig>; // for nested routes beforeEnter?: (to: Route, from: Route, next: Function) => void; meta?: any; // 2.6.0+ caseSensitive?: boolean; // use case sensitive match? (default: false) pathToRegexpOptions?: Object; // path-to-regexp options for compiling regex }
mode
type:
stringdefault:
"hash" (in browser) | "abstract" (in Node.js)available values:
"hash" | "history" | "abstract"Configure the router mode.
hash: uses the URL hash for routing. Works in all Vue-supported browsers, including those that do not support HTML5 History API.history: requires HTML5 History API and server config. See HTML5 History Mode.abstract: works in all JavaScript environments, e.g. server-side with Node.js. The router will automatically be forced into this mode if no browser API is present.
base
type:
stringdefault:
"/"The base URL of the app. For example, if the entire single page application is served under
/app/, thenbaseshould use the value"/app/".
linkActiveClass
type:
stringdefault:
"router-link-active"Globally configure
<router-link>default active class. Also see router-link.
linkExactActiveClass
2.5.0+
type:
stringdefault:
"router-link-exact-active"Globally configure
<router-link>default active class for exact matches. Also see router-link.
scrollBehavior
type:
FunctionSignature:
type PositionDescriptor = { x: number, y: number } | { selector: string } | ?{} type scrollBehaviorHandler = ( to: Route, from: Route, savedPosition?: { x: number, y: number } ) => PositionDescriptor | Promise<PositionDescriptor>For more details see Scroll Behavior.
parseQuery / stringifyQuery
2.4.0+
type:
FunctionProvide custom query string parse / stringify functions. Overrides the default.
fallback
2.6.0+
type:
booleanControls whether the router should fallback to
hashmode when the browser does not supporthistory.pushState. Defaults totrue.Setting this to
falseessentially makes everyrouter-linknavigation a full page refresh in IE9. This is useful when the app is server-rendered and needs to work in IE9, because a hash mode URL does not work with SSR.