Lui*_*izo 4 javascript alert react-native
我想在几秒钟后自动关闭警报,而无需用户自己做。
如果可能的话,我想使用Alert(而不是AlertIOS)来做到这一点,但是如果只有AlertIOS有,那么我想我别无选择。
非常感谢你!
我建议您使用Modal组件
<Modal
animationType={"slide"}
transparent={false}
visible={this.state.modalVisible}></Modal>
Run Code Online (Sandbox Code Playgroud)
因此,您可以在函数中调用setTimeout()来更新状态变量modalVisible以显示/隐藏它。可以从官方文档(https://facebook.github.io/react-native/docs/modal.html)中找到更多示例。