微信小程序里的定时器
clearTimeout(timerName) var timerName = setTimeout(function() { that.getParkList() }, 3000)
微信小程序里的循环定时器
var that = this; var times = 0 let serverCode = this.data.serverCode if (e) { times = e } var i = setInterval(function () { times++ if (times >= 5) { that.audioPause() that.setData({ color: "#ff6f10", disabled: false, getCode: "暂无应答,点击重新呼叫", }) clearInterval(i) } else if (!that.data.serverCode) { //这里有一个坑,setData的时候,如果想要即时的data数据做判断 // 是不能使用serverCode来做判断的,因为这个值不是已经动态改变的 console.log('11707') that.audioPause() that.setData({ color: "#ff6f10", disabled: false, getCode: "服务器未响应,点击重新呼叫", }) clearInterval(i) } else { that.setData({ getCode: "正在呼叫管理员..." + times + "s", color: "#999", disabled: true }) } }, 1000)
vue里的定时器
// mounted() { // this.timer = setTimeout(() => { // //在这里实现事件 // }, 5000) // }, // beforeDestroy() { // clearTimeout(this.timer) // },