ctx.route
当前路由匹配信息,与 React Router 的 route 概念对应,用于获取当前匹配的路由配置、参数等。通常与 ctx.router、ctx.location 配合使用。
适用场景
注意:
ctx.route仅在存在路由上下文的 RunJS 环境中可用(如页面内的 JSBlock、Flow 页面等);在纯后端或无路由的上下文(如工作流)中可能为空。
类型定义
常用字段
与 ctx.router、ctx.location 的关系
ctx.route 侧重「匹配到的路由配置」,ctx.location 侧重「当前 URL 位置」,二者配合可完整描述当前路由状态。
示例
读取 pathname
根据 params 做分支
在 Flow 页面中展示
相关
- ctx.router:路由导航,
ctx.router.navigate()改变路径后,ctx.route会随之更新 - ctx.location:当前 URL 位置(pathname、search、hash、state),与
ctx.route配合使用

