本文介绍了如何在一定时间后自动关闭警报React Native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在几秒钟后自动关闭警报,而无需用户自己做。
I would like to automatically close an alert after a couple of seconds without having the user do it themselves.
如果可能的话,我想使用Alert(不是AlertIOS),但是如果只有AlertIOS的话,我想我别无选择。
If possible I would like to do this using Alert (not AlertIOS), but if only AlertIOS has it then I guess I have no other choice.
非常感谢!
推荐答案我建议您使用模态组件
<Modal animationType={"slide"} transparent={false} visible={this.state.modalVisible}></Modal>因此您可以在函数中调用setTimeout()来更新状态变量modalVisible以显示/隐藏它。在官方文档中可以找到更多示例( https://facebook.github。 io / react-native / docs / modal.html )
So you can call setTimeout() in your function to update the state variable modalVisible to show / hide it. More examples can be found here from the official doc (facebook.github.io/react-native/docs/modal.html)
更多推荐
如何在一定时间后自动关闭警报React Native
发布评论