zoukankan      html  css  js  c++  java
  • 定时器

    微信小程序里的定时器

                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)
      // },
    君不见,高堂明镜悲白发,朝如青丝暮成雪
  • 相关阅读:
    Add two numbers
    House Robber && House Robber II
    Clone Graph
    224. Basic Calculator
    29. Divide Two Integers
    365. Water and Jug Problem
    435. Non-overlapping Intervals
    452. Minimum Number of Arrows to Burst Balloons
    138. Copy List with Random Pointer
    43. Multiply Strings
  • 原文地址:https://www.cnblogs.com/lzhflzjx/p/13517518.html
Copyright © 2011-2022 走看看