Interface AsyncImportProps

路由 props

interface AsyncImportProps {
    action?: boolean | ActionFunction;
    autoReplaceTitle?: boolean;
    beforeRouter?: BeforeRouterHook;
    BUILD_ENV?: string;
    caseSensitive?: boolean;
    Component?: null | ComponentType<{}>;
    contentProps?: HTMLAttributes<HTMLDivElement>;
    createProps: AppRouterProps;
    disableBreadcrumbJump?: boolean;
    dispatchBeforeRouter?: <
        Result = any,
        AddProps extends RouteProps = RouteProps,
    >(
        addProps?: AddProps,
    ) => Promise<Result>;
    element: Promise<any>;
    ErrorBoundary?: null | ComponentType<{}>;
    errorElement?: ReactNode;
    handle?: any;
    hasErrorBoundary?: boolean;
    HydrateFallback?: null | ComponentType<{}>;
    hydrateFallbackElement?: ReactNode;
    id?: string;
    importErrorFC?: FC<ImportErrorProps>;
    importLoadingFC?: FC<ImportLoadingProps>;
    index?: boolean;
    isStatic?: boolean;
    keywords?: string[];
    lazy?:
        | LazyRouteFunction<NonIndexRouteObject>
        | LazyRouteFunction<IndexRouteObject>;
    loader?: boolean | LoaderFunction<any>;
    location: RouteLocation;
    name: string;
    navigate: NavigateFunction;
    params: Record<string, unknown>;
    parent?: RouteConfig;
    parentNamePath?: string[];
    path?: string;
    permissionCode?: string;
    permissionCodeMap?: Record<string, boolean>;
    query: Record<string, unknown>;
    redirectTo?: string;
    routes?: RouteConfig[];
    shouldRevalidate?: ShouldRevalidateFunction;
    title?: string;
    type?: string;
    [key: string]: any;
}

Hierarchy (View Summary)

Indexable

  • [key: string]: any

Properties

action?: boolean | ActionFunction
autoReplaceTitle?: boolean

自动替换页面标题

beforeRouter?: BeforeRouterHook
BUILD_ENV?: string

构建环境变量

caseSensitive?: boolean
Component?: null | ComponentType<{}>
contentProps?: HTMLAttributes<HTMLDivElement>

路由容器 props

createProps: AppRouterProps

根路由创建时传入的 props

disableBreadcrumbJump?: boolean

禁用面包屑跳转 某些带参数的 url 需要激活此选项以禁止点击面包屑时跳转页面

dispatchBeforeRouter?: <Result = any, AddProps extends RouteProps = RouteProps>(
    addProps?: AddProps,
) => Promise<Result>

主动触发当前路由的私有 BeforeRouter 函数, 在 BeforeRouter 中存在数据准备动作且后续需要更新的情况下非常有用

  • 此方法只会触发私有 BeforeRouter 钩子
  • 触发 props 更新但不会重新加载组件
element: Promise<any>
ErrorBoundary?: null | ComponentType<{}>
errorElement?: ReactNode
handle?: any
hasErrorBoundary?: boolean
HydrateFallback?: null | ComponentType<{}>
hydrateFallbackElement?: ReactNode
id?: string
importErrorFC?: FC<ImportErrorProps>

路由导入错误时渲染的组件

importLoadingFC?: FC<ImportLoadingProps>

路由导入时渲染的组件

index?: boolean
isStatic?: boolean

是否静态, 默认 false, 非静态下 url 变更将强制组件重写渲染

keywords?: string[]

关键字 用于检索

lazy?:
    | LazyRouteFunction<NonIndexRouteObject>
    | LazyRouteFunction<IndexRouteObject>
loader?: boolean | LoaderFunction<any>
location: RouteLocation

react-router location 对象

name: string

路由的 name,全局唯一

navigate: NavigateFunction

react-router 路由跳转方法

params: Record<string, unknown>

路由参数

parent?: RouteConfig

父级路由 auto-routes 会根据 RouteConfig 层级自动注入,无需手动声明

parentNamePath?: string[]

嵌套层级路径,路由 name 的数组 用明确路由嵌套层级 auto-routes 会根据 RouteConfig 层级自动注入,无需手动声明

path?: string

路径

permissionCode?: string

权限代码, 控制路由能否被访问

permissionCodeMap?: Record<string, boolean>

权限码映射表

query: Record<string, unknown>

由 location.search 转换来的对象

redirectTo?: string

重定向

routes?: RouteConfig[]

子路由 子路由 path 与父级不存在嵌套关系

shouldRevalidate?: ShouldRevalidateFunction
title?: string

页面标题

type?: string

自定义参数, 视情况而定