如何使用 expo router 从嵌套路由内导航回根索引

问题描述 投票:0回答:1

我有这样的布局。

app/
  (auth)
      _layout.tsx
      index.tsx
      sign-in.tsx
  _layout.tsx
  dashboard.tsx
  index.tsx

当我获得身份验证令牌时,从 Sign-in.tsx 中调用 router.replace("/") ,这会将我导航到(身份验证)内的索引而不是根索引。那么如何从 (auth)/signin.tsx 中导航到根索引?

发现未解决的问题https://github.com/expo/router/issues/365

expo expo-router
1个回答
0
投票

因此,鉴于上述结构,当我未进行身份验证时路由到根 index.tsx 时,我会调用 router.replace("/(auth)"),然后当我导航回根索引时,它将无法工作。使用 router.push("/(auth)") 确实有效,所以我的感觉是 expo router 只能访问历史记录中的路由。

© www.soinside.com 2019 - 2024. All rights reserved.