跳到主要内容
版本:4.x

router

类型

router

参数

CustomRouteBuilder

(routeContext: CustomRouteContext,routeOptions: Record<string, any>) => CustomRouteConfig
参数类型
routeContextCustomRouteContext
routeOptionsRecord<string, any>

SharedValue

参数类型
valueT

CustomRouteContext

参数类型
primaryAnimationSharedValue<number>
primaryAnimationStatusSharedValue<number>
secondaryAnimationSharedValue<number>
secondaryAnimationStatusSharedValue<number>
userGestureInProgressSharedValue<number>
startUserGesture() => void
stopUserGesture() => void
didPop() => void

CustomRouteConfig

参数类型必填
opaqueboolean
maintainStateboolean
transitionDurationnumber
reverseTransitionDurationnumber
barrierColorstring
barrierDismissibleboolean
barrierLabelstring
canTransitionToboolean
canTransitionFromboolean
handlePrimaryAnimationRouteAnimationHandler
handleSecondaryAnimationRouteAnimationHandler
handlePreviousPageAnimationRouteAnimationHandler
allowEnterRouteSnapshottingboolean
allowExitRouteSnapshottingboolean
fullscreenDragboolean
popGestureDirection"horizontal" or "vertical" or "multi"

RouteAnimationHandler

() => { [key: string]: any; }

router

自定义路由

支持情况:

参考文档

addRouteBuilder

添加自定义路由配置

支持情况:

参考文档

(routeType: string, routeBuilder: CustomRouteBuilder) => void
参数类型说明
routeTypestring路由类型
routeBuilderCustomRouteBuilder路由动画定义函数

getRouteContext

获取页面对应的自定义路由上下文对象

支持情况:

参考文档

(instance: TaroGeneral.IAnyObject) => CustomRouteContext
参数类型说明
instanceTaroGeneral.IAnyObject页面/自定义组件实例

removeRouteBuilder

移除自定义路由配置

支持情况:

参考文档

(routeType: string) => void
参数类型说明
routeTypestring路由类型