当前位置:网站首页>Detailed tutorial on the use of setinterval timing function of wechat applet
Detailed tutorial on the use of setinterval timing function of wechat applet
2022-04-23 14:05:00 【one billion twenty-nine million one hundred and seventy-nine th】
1、setInterval The understanding of the
(1)setInterval understand
setInterval Timing function , Is how long to delay the non-stop call setInterval The function in , I want to know more about setInterval function , Let's take a look first setInterval Function components .
(2)setInterval form
setInterval(function () {}, Time ).function () {} Just keep executing functions , Time is how long it's delayed. Keep executing , a key function () {} function
Concrete example :
setInterval(function () {
//.toClock1() Is a concrete function , Write outside
_this.toClock1();}, 6000);
(3)setInterval Need to be closed
Use clearInterval() To close , See the following for specific use
clearInterval()
2、setInterval Put it in wechat applet onshow In the function
onShow: Triggered when this page is displayed or when you jump back to the applet from the background , Triggered when returning from the jump page , Can't pass parameters
3、setInterval Specific use
(1) Set global variables timer(timer Whatever the )
// In wechat applet data Write the following code in ,timer Global variables
data: {
timer: null,
},
(2)onshow Write setInterval function
onShow: function () {
const _this = this
// Timer The function is assigned to timer convenient clearInterval() Use
_this.data.timer = setInterval(
function () {
_this.toClock1();
}, 6000);
_this.setData({
timer:_this.data.timer
});
},
toClock1() function
// Contents of timing function execution Play by yourself Write your own code
toClock1(){
console.log(this.data.timer)
}
3、 Leave the current page and close setInterval Timing function
Code placed in onhide inside
onHide: function () {
// close clearInterval Timing function
clearInterval(this.data.timer);
this.setData({
timer: null
});
console.log(this.data.timer)
},
WeChat applet more practical skills, pay attention to the official account below.
版权声明
本文为[one billion twenty-nine million one hundred and seventy-nine th]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401297853.html
边栏推荐
- Strange bug of cnpm
- Chapter I review of e-commerce spike products
- 关于pthread多线程一些好文章
- China creates vast research infrastructure to support ambitious climate goals
- 微信小程序 input隐藏和不可操作的设置
- JS 力扣刷题 103. 二叉树的锯齿形层序遍历
- Business case | how to promote the activity of sports and health app users? It is enough to do these points well
- leetcode--380. O (1) time insertion, deletion and acquisition of random elements
- 生产环境——
- crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
猜你喜欢
smart-doc + torna生成接口文档
What is the difference between blue-green publishing, rolling publishing and gray publishing?
STM32 learning record 0007 - new project (based on register version)
33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?
Chrome插件 之 Selenium IDE、XPath 安装
Mock测试
Node接入支付宝开放平台的沙箱实现支付功能
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
Pycharm连接远程服务器并实现远程调试
Qt Designer怎样加入资源文件
随机推荐
微信小程序进行蓝牙初始化、搜索附近蓝牙设备及连接指定蓝牙(一)
生成随机高质量符合高斯分布的随机数
JS force deduction brush question 103 Zigzag sequence traversal of binary tree
AtomicIntegerArray源码分析与感悟
json反序列化匿名数组/对象
The latest development of fed digital currency
关于pthread多线程一些好文章
linux安装mysql后修改密码
JS brain burning interview question reward
基於CM管理的CDH集群集成Phoenix
室内外地图切换(室内基于ibeacons三点定位)
分页SQL
Introduction to spark basic operation
As a junior college student, I studied hard in closed doors for 56 days, won Ali offer with tears, five rounds of interviews and six hours of soul torture
Cdh6 based on CM management 3.2 cluster integration atlas 2 one
分库分表 & ShardingSphere
Nodejs安装及环境配置
封装logging模块
微信小程序的订阅号开发(消息推送)
Neuron and neural network