This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
路由设置
编辑页面
了解如何在 Expo Router 中使用静态属性配置布局。
警告:
unstable_settings目前无法与 async routes 配合使用(仅限开发环境)。这就是该功能被标记为 unstable 的原因。
anchor
深度链接到某个路由时,你可能希望为用户提供一个“返回”按钮。anchor 设置堆栈的默认屏幕,并且应与有效的文件名匹配(不包含扩展名)。
srcapp_layout.tsxindex.tsxother.tsxsrc/app/_layout.tsx
现在,直接深度链接到 /other 或重新加载页面时,仍然会显示返回箭头。
使用 array syntax (foo,bar) 时,你可以在 unstable_settings 对象中指定某个分组的名称,以定位到特定片段。
other.tsx
anchor 仅在深度链接到某个路由时使用。在应用内导航期间,你要导航到的路由将成为锚点路由。若要同时在目标路由下方加载锚点路由,请在 <Link /> 组件上使用 withAnchor 属性。命令式 API 接受相同的选项。
// If this navigates to a new _layout, load the anchor route below the target route <Link href="/route" withAnchor />; router.push('/route', { withAnchor: true });
initialRouteName
initialRouteName已弃用。请改用anchor。