【发布时间】:2017-08-07 11:07:18
【问题描述】:
按下按钮时导航不起作用。这是我的登录页面。我想退出 onPressLogout() 从主屏幕到登录屏幕
index.js
class Profile extends Component{
static propTypes = {
navigator: PropTypes.shape({
getCurrentRoutes: PropTypes.func,
jumpTo: PropTypes.func,
}),
}
onPressLogout() {
const routeStack = this.props.navigator.getCurrentRoutes();
this.props.navigator.jumpTo(routeStack[0]);
}
render(){
return (
<Container>
<View style={styles.container}>
<Header>
<Button
style={styles.button}
onPress={() => this.onPressLogout()}
>
<Icon name="ios-power" />
</Button>
<Title>Logout</Title>
</Header>
</Container>
);
}
在路由栈中
const routeStack = [
{ name: 'Login', component: Login},
]
【问题讨论】:
标签: javascript react-native navigation