我构建了一个具有“列表模式”和“项目模式”的应用程序。在列表模式下,您将有一个“项目”列表。然后,当您选择一个项目时,您将在一个详细信息视图中导航,该视图具有一个带有标签(@ react-navigation / bottom-tabs)的底部栏。
现在,当我处于列表模式时,通过react-navigation v4,我可以在特定选项卡中的列表中进行导航,但是我不知道如何使用react-navigation v5来实现。 / p>
我基本上有这种结构
(node:310) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at Object.run (/home/runner/Utki-the-bot/commands/unban.js:11:47)
at Client.<anonymous> (/home/runner/Utki-the-bot/index.js:71:42)
at Client.emit (events.js:315:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/Utki-the-bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Utki-the-bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/Utki-the-bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/Utki-the-bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/Utki-the-bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/Utki-the-bot/node_modules/ws/lib/event-target.js:125:16)
(node:310) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:310) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我可以轻松导航
<NavigationContainer>
<Stack.Navigator headerMode="none">
<Stack.Screen name="List" component={ItemsScreen} />
<Stack.Screen name="Item" component={MainTabNavigator} />
</Stack.Navigator>
</NavigationContainer>;
但是,如果这样做,我将在主视图中而不是在底部栏中进行导航。
关于如何在选择第二个选项卡的情况下以项目模式移动应用程序的任何想法?
答案 0 :(得分:2)
像下面这样导航时必须指定屏幕
此处“选项卡”是堆栈中保存选项卡导航器的屏幕,“设置”是选项卡中的屏幕。 这将导航到“标签”屏幕,然后切换到“设置”标签。
<Button title="Navigate" onPress={()=>navigation.navigate('tabs',{screen:'Settings'})}/>