React Native中定时器的使用
来源:互联网 发布:snapgene mac 编辑:程序博客网 时间:2024/05/25 20:00
React Native中定时器的使用
React Native中定时器的使用分为ES5和ES6两种,前者使用较为麻烦
ES5中使用方式
- 引入计时器类库
var TimerMixin = require('react-timer-mixin');
- 注册计时器
mixins: [TimerMixin],
- 添加定时器
this.timer = this.setInterval(function() { }, 3000)
注意定时器开启就得有清除,一般在componentWillUnMount调用,图形卸载时清楚定时器也好理解
componentWillUnMount() { this.setInterval && clearInterval(this.setInterval) }
ES6中使用方式
很简单
this.timer = setTimeout(function() { alert('3秒后弹出') }, 3000);
同样定时器开启就得有清除
this.timer && clearTimeout(this.timer)
0 0
- React Native中定时器的使用
- react native 定时器的使用
- React Native -19.React Native Timer定时器的使用
- react-native中抽屉的使用(react-native-drawer)
- React-native中DatePickerAndroid的使用
- React Native中ListView的简单使用
- React Native中组件的封装使用
- React-Native中导航组件react-navigation的使用
- react-native 定时器
- react native 中 使用 Redux
- react-native中使用underscore
- react native中使用react-native-viewpager实现的商品展示添加点击事件
- React Native中react-native-baidu-map的安装与使用
- 【React Native开发】- React Navigation的使用
- React-Native 中 StackNavigator的跳转界面的使用
- 【React native】Webview的使用
- [React Native]StatusBar的使用
- react native ref的使用
- 利用ffmpeg对视频进行裁剪与拼接
- 关于double-check 和barrier
- Java内存区域 JVM运行时数据区
- SpringMVC中的视图和视图解析器
- iOS NSNull,nil,Nil的区别
- React Native中定时器的使用
- Zookeeper的watcher数据变更通知机制
- spring的配置文件中mvc:view-controller path使用方法
- Third Maximum Number
- 全面分析 Spring 的编程式事务管理及声明式事务管理
- 在页面里面播放音频文件
- Python学习笔记 __slots__ 限制类属性
- 链表的构建与排序
- springmvc之视图和视图解析器