Skip to content

RouteConfig ​

A single route configuration record. Since uni-app x adopts the static pages.json page model, the page path is the route path, and path must match the registration in pages.json.

ts
import type { RouteConfig } from '@meng-xi/unix-router'

export const routes: RouteConfig[] = [
	{ path: 'pages/index/index', name: 'home', meta: { title: 'Home', isTab: true } },
	{ path: 'pages/about/about', name: 'about', meta: { title: 'About' } },
	{
		path: 'pages/admin/admin',
		name: 'admin',
		meta: { title: 'Admin', requireAuth: true },
		beforeEnter: (to, from) => {
			return isAdmin() ? true : { name: 'home' }
		}
	}
]

Fields ​

FieldTypeDefaultDescription
pathstring—Required. Page path, must match pages.json (e.g. pages/index/index), without a leading slash; normalized to /pages/index/index after parsing
namestring—Named route name, for navigation by name; a duplicate name logs a warning and the later one overrides the earlier one
metaRouteMeta—Route metadata (title / isTab / requireAuth)
redirectRouteLocationRaw—Reserved field (the redirect target). Not consumed by the current matcher / router; declared in the type for forward compatibility
beforeEnterNavigationGuard | NavigationGuard[]—Route-exclusive before guard: a function or an array, runs only when entering this route (before the global beforeResolve)

Released under the MIT License.