如何在一定时间后自动关闭警报React Native

编程入门 行业动态 更新时间:2024-10-11 15:18:37
本文介绍了如何在一定时间后自动关闭警报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

本文发布于:2023-11-27 13:20:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638243.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在一   警报   自动关闭   时间   Native

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!