我需要从NavigatorIOS左键单击打开侧面菜单抽屉(DrawerNavigator),我该怎么做?得到错误。 undefined不是一个对象(评估' _this2.props.navigation.navigate')
从侧面菜单中,用户打开了一个登录屏幕,用户点击NavigatorIOS上的左上菜单按钮。
export default class NavigatorIOSApp extends React.Component {
render() {
return (
<NavigatorIOS
initialRoute={{
component: LoginScreen,
title: 'Sign In',
passProps: {index: 1},
leftButtonTitle: "Menu",
onLeftButtonPress: () => {
this.props.callMenu()
},
}}
style={{flex: 1}}
/>
);
}
}
class LoginScreen extends Component {
callMenu()
{
alert("hi");
//this.props.navigation.navigate('DrawerOpen')
}
render() {
return (
<View style={styles.container}> Hello
</view>
)
}
}
我试过
onLeftButtonPress: () => {
this.props.navigation.navigate('DrawerOpen')
}
但是错误
undefined is not an object (evaluating '_this2.props.navigation.navigate')