我对react-native还是新手,
所以我尝试的是制作一个简单的应用程序 有按钮,按下它即可打开警报 如这段代码
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'}])
}
}
现在我想在按钮单击上打开模态,而不仅仅是警报 我试着读一下这个 http://facebook.github.io/react-native/docs/modal.html#content 但我真的输了 如何使用react-native制作模态?
最佳答案
您可以使用如下所示的模态。
<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。
关于javascript - 单击react-native android时创建模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36771581/