1.5 KiB
1.5 KiB
关于Nuxt的一些API
Components 组件
Composables 复合函数
Utils 工具
definePageMeta(meta: PageMeta): void
定义页面属性
interface PageMeta {
validate?: (route: RouteLocationNormalized) => boolean | Promise<boolean> | Partial<NuxtError> | Promise<Partial<NuxtError>>
redirect?: RouteRecordRedirectOption
name?: string
path?: string
props?: RouteRecordRaw['props']
alias?: string | string[]
pageTransition?: boolean | TransitionProps
layoutTransition?: boolean | TransitionProps
viewTransition?: boolean | 'always'
key?: false | string | ((route: RouteLocationNormalizedLoaded) => string)
keepalive?: boolean | KeepAliveProps
layout?: false | LayoutKey | Ref<LayoutKey> | ComputedRef<LayoutKey>
middleware?: MiddlewareKey | NavigationGuard | Array<MiddlewareKey | NavigationGuard>
scrollToTop?: boolean | ((to: RouteLocationNormalizedLoaded, from: RouteLocationNormalizedLoaded) => boolean)
[key: string]: unknown
}
- layoutTransition
设置要应用于当前布局的过渡的名称。您还可以将此值设置为 false 以禁用布局过渡。
Type: boolean | TransitionProps
- pageTransition
设置要应用于当前页面的过渡的名称。您还可以将此值设置为 false 以禁用布局过渡。
Type: boolean | TransitionProps
onBeforeRouteLeave(leaveGuard): void
eg: '/pages/index.vue'
当前路由离开前的拦截
leaveGuard: Navigation Guard. 导航护卫。
(to, from, next)