【发布时间】:2019-11-02 10:07:18
【问题描述】:
我有问题,我想从 Modal 登录导航到注册。这个问题是怎么解决的?
如何才能在模态中导航?
import React, { Component } from 'react';
import { Alert, StyleSheet, Text, TouchableOpacity, View, Dimensions, TextInput } from 'react-native';
import Modal from 'react-native-modalbox';
import Lock from '../../../assets/icon/lock.svg';
import User from '../../../assets/icon/user.svg';
var screen = Dimensions.get('window');
class Login extends Component {
constructor(props) {
super(props);
}
showLogin = () => {
this.refs.myLogin.open();
}
closeLogin = () => {
this.refs.myLogin.close();
}
render() {
return (
<Modal
ref={"myLogin"}
style={{
borderRadius: 10,
width: screen.width - 80,
shadowRadius: 10,
height: 300,
}}
position='center'
backdrop={true}
/>
)
}
}
还有这个按钮
<TouchableOpacity onPress={() => this.props.navigation.navigate('Register')}>
<Text style={{ color: '#024379', fontWeight: 'bold' }}>Daftar Disini</Text>
</TouchableOpacity>
【问题讨论】:
-
创建导航服务,然后导入你想要的地方并使用它
-
也看文档 => reactnavigation.org/docs/en/…
标签: react-native react-navigation