在点击react-native android上创build模式

我在反应本土还是新的,

所以我试着做一个简单的应用程序,当按下它只是打开警报作为这个代码的button

class MyFirstReactapril extends Component{ render(){ return( <View style={styles.container}> <Text style={styles.welcome}> Welcome Nesreen</Text> <TouchableHighlight style={styles.button} onPress={this.showAlert}> <Text style={styles.buttonText}>Myalert</Text> </TouchableHighlight> </View> ) } showAlert(){ Alert.alert('Fast Donation','', [{text : 'Donate now'},{text : 'add to Container'}]) } } 

现在我想打开莫代尔button点击不只是警报我试图阅读这个http://facebook.github.io/react-native/docs/modal.html#content,但我真的失去了如何使模态使用react-本机?

你可以使用下面的模态。

 <Modal visible={this.state.isModalOpen} onRequestClose={() => this.setState({isModalOpen: false})} animationType={"slide"} transparent={false}> <View> //Create your modal view inside this </View> </Modal> 

在你的showAlert()方法中,将isModalOpen设置为true。