# router.addRouteBuilder(string routeType, CustomRouteBuilder routeBuilder)
小程序插件:不支持
相关文档: 自定义路由
# 功能描述
添加自定义路由配置
# 参数
# string routeType
路由类型
# CustomRouteBuilder routeBuilder
builder
函数
# 示例代码
// 定义自定义效果,从右侧推入
const slideRouteBuilder = (customRouteContext) => {
const { primaryAnimation } = customRouteContext
const handlePrimaryAnimation = () => {
'worklet'
const transX = windowWidth * (1 - primaryAnimation.value)
return {
transform: `translateX(${transX}px)`,
}
}
return {
handlePrimaryAnimation
}
}
wx.router.addRouteBuilder('slide', slideRouteBuilder)
// 使用自定义路由
wx.navigateTo({
url: 'xxx',
routeType: 'slide'
})