react-native - 如何在其他屏幕的反应导航中导入底部导航器
问题描述
我创建了一个底部导航器,使用react-navigation
. 如何将它用于底部导航器中未包含的其他屏幕?
const Stack = createStackNavigator({
intro: {
screen: IntroSlides
},
dashboard: {
screen: createBottomTabNavigator({
inbox: {
screen: Inbox,
navigationOptions: ({ navigation }) => ({
tabBarIcon: () => (
<Image resizeMode={'contain'} style={styles.icon} source={require('./src/assets/MyProfileIcon.png')} />
),
title: 'Profile',
}),
},
favourite: {
screen: Favourite,
navigationOptions: ({ navigation }) => ({
tabBarIcon: () => (
<Image resizeMode={'contain'} style={styles.icon} source={require('./src/assets/FavouriteIcon.png')} />
),
title: 'Favourite',
}),
解决方案
将您的其他项目/屏幕放在堆栈导航器中:
const Bottom = createBottomTabNavigator({
item1: {screen: Screen1},
item2: {screen: Screen2},
},{
initialRouteName: "item1",
}
)
export default createStackNavigator({
tabs: Bottom,
item3: Screen3, // your other screen
})
如果你想从 item3 屏幕中隐藏 stacknavigator,你可以在你的组件中使用它:
static navigationOptions = ({ navigation, screenProps }) => ({
header: null
});
推荐阅读
- c - 内部温度 Arduino
- git - 如何删除发布但不删除标签?
- python - 我怎样才能不从此代码中获取列表索引超出范围错误?
- exception - 通过代码在新的 JVM 上启动 JavaFX 应用程序
- android - 颤振:错误:找不到吸气剂:“暂停”。案例 AppLifecycleState.suspending
- android - Firebase Auth 无需登录即可注册
- paypal - PayPal Adaptive Payments 自动退还订单
- python - 将numpy的日期时间数组与时间戳进行比较
- javascript - 使用给定的 html 和 javascript(脚本标签)打开新窗口
- python - IndexError:维度超出范围(预计在 [-1, 0] 范围内,但得到 1)