抽屉导航未打开

时间:2019-01-21 18:34:21

标签: react-native react-navigation react-navigation-drawer

我无法打开抽屉。通过滑动最左边的屏幕,抽屉应该已经打开,但是什么也没发生。这是为什么?下面是代码:

App.js

const MyDrawerNavigator = createDrawerNavigator({
  Home: {
    screen: MyHomeScreen,
  },
  Notifications: {
    screen: MyNotificationsScreen,
  },
});

export default createAppContainer(MyDrawerNavigator);

MyHomeScreen.js

export default class MyHomeScreen extends React.Component {
  static navigationOptions = {
    drawerLabel: 'Home',
  };

  render() {
    return (
      <Button
        onPress={() => this.props.navigation.navigate('Notifications')}
        title="Go to notifications"
      />
    );
  }
}

MyNotificationsScreen.js

导出默认类MyNotificationsScreen扩展了React.Component {   静态navigationOptions = {     抽屉标签:“通知”,   };

render(){     返回(        this.props.navigation.goBack()}         title =“回到家”       />     );   } }

0 个答案:

没有答案