如何使用react native在选项卡外导航?

时间:2019-09-05 07:48:51

标签: reactjs react-native react-router react-navigation

我想从标签屏幕中导航到另一个屏幕。

我的问题是我无法在选项卡外导航。

当我按下花朵图像以导航到我的登录屏幕时,登录屏幕将在当前选项卡中打开!

flower image

login page

这是我的堆栈导航器。该项目包含标签导航

import { createAppContainer, createStackNavigator, createDrawerNavigator } from 'react-navigation';

const AppStackNavigator = createStackNavigator({

    Login: Login,
    Developer: Developer,
    Projects: Projects,

},

    {
        headerMode: 'none',
        navigationOptions: {
            headerVisible: false,
        }
    }); 

这是我的标签导航器屏幕:

const TabNavigator = createMaterialTopTabNavigator({



    Photo: {
        screen: check_note_type2,

        navigationOptions: {
            tabBarIcon: (<Image
                style={{resizeMode:'contain', width: wp('4%'), height: hp('5%'), tintColor: '#bfb288' }}
                source={require('../assets/photo.png')} />)
        }
    },

    Voice: {
        screen: check_note_type3,
        navigationOptions: {
            tabBarIcon: (<Image
                style={{ resizeMode:'contain',width: wp('4%'), height: hp('5%'), tintColor: '#bfb288' }}
                source={require('../assets/voice.png')} />)
        }
    },


    Text: {
        screen: check_note_type4,
        navigationOptions: {
            tabBarIcon: (<Image
                style={{ resizeMode:'contain',width: hp('4%'), height: hp('5%'), tintColor: '#bfb288' }}
                source={require('../assets/note.png')} />)
        }
    },

1 个答案:

答案 0 :(得分:0)

在这种情况下,您可以通过react-navigation提供的API在组件外部使用导航道具:

https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html