假设我有3页。 Home
,Settings
,Page
。
我有
<BottomTab.Navigator>
<BottomTab.Screen name="Home" component={HomeScreen}/>
<BottomTab.Screen name="Settings" component={SettingsScreen}/>
<BottomTab.Screen name="Page" component={PageScreen}/>
</BottomTab.Navigator>
它们的全部3个都显示在底部导航中。
我想从底部导航访问Home
和Settings
,并从Page
页面中的链接访问Home
。
我的问题是有一种方法可以从底部导航隐藏Page
,但仍然从其他页面链接到它并传递道具和数据给它?
我曾尝试从Page
中删除<BottomTab.Screen>
,但是后来我无法使用navigation.navigate("Page")
导航到该页面,因此我需要这样做,以便可以将道具和数据传递到该页面]
以下是来自应用的一些代码。该代码是通过expo
生成的// App.js render ( <NavigationContainer ref={containerRef} initialState={initialNavigationState} > <Stack.Navigator> <Stack.Screen name="Root" component={BottomTabNavigator} /> </Stack.Navigator> </NavigationContainer> </View> )
//bottomTabNavigator component <RootStack.Navigator initialRouteName={INITIAL_ROUTE_NAME}> <RootStack.Screen name="Home" component={HomeScreen} options={{ title: "Get Started", tabBarIcon: ({ focused }) => ( <TabBarIcon focused={focused} name="md-code-working" /> ), }} /> <RootStack.Screen name="Profile" component={ProfileScreen} options={{ tabBarVisible: false, title: "Your Profile", tabBarIcon: ({ focused }) => ( <TabBarIcon focused={focused} name="md-book" /> ), }} /> </RootStack.Navigator>
谢谢
假设我有3页。主页,设置,页面。我有
我不确定我是否正确理解您的意思,但是我认为这就是您想要的。
https://reactnavigation.org/docs/stack-navigator/
安装所有内容后,您可以执行以下操作
const RootStackNavigator = () => {
return(
<RootStack.Navigator>
<RootStack.Screen name="main" component = {BottomStackScreen}/>
<RootStack.Screen name="Page" component={PageScreen} />
</RootStack.Navigator>
)
}