如何使用嵌套导航器从抽屉导航器导航到另一个导航器?

时间:2017-11-13 13:57:21

标签: react-native react-navigation

导航器结构

-DrawerNavigators
 --TimelineNavigators
   --- Screen1(initialRoute)
   --- Screen2
- SettingsScreen

TimeLine Navigator

export const TimelineNavigators = StackNavigator({
    'screen1': { screen: Timeline, navigationOptions:Screen1NavigatorOptions() },
    'screen2': { screen: LiveMap,  navigationOptions:Screen2NavigatorOptions() },
},{initialRoute: 'screen1'});

抽屉

    const routeConfiguration = {
        'TimelineNavigators': { screen: TimelineNavigation, navigationOptions: timeLineDrawerOptions },
        'SettingsScreen': { screen: SettingsScreen , navigationOptions: settingsDrawerOptions },
    };

    export const NavigatorAuth = DrawerNavigator(routeConfiguration, drawer

Options());

设置屏幕

import { View, Text, Button } from 'react-native';
import { NavigationActions } from 'react-navigation'

class Settings extends Component {
    render() {
        return (
            <View>
                <Button onPress={()=> this.props.navigation.navigate('screen2')}  title="Go to Screen 2"/>
            </View>
        );
    }
}

export default Settings;

我点击了&#39;转到第2屏幕&#39;按钮,然后不进入屏幕2。

当前行为

在SettingsScreen上点击按钮(onPress = {()=&gt; {navigation.navigate(&#39; Screen2&#39;)})时,没有任何反应。屏幕没有改变。是bug吗?

预期行为

在SettingsScreen上点击按钮(onPress = {()=&gt; {navigation.navigate(&#39; Screen2&#39;)})时,必须打开Screen2。

环境

|反应导航| 1.0.0-beta.19
|反应原生的0.49.5
|节点| 6.11.2
| npm或纱线| 5.5.1

0 个答案:

没有答案