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)
      // },
    君不见,高堂明镜悲白发,朝如青丝暮成雪
  • 相关阅读:
    POJ 2186 Popular Cows
    POJ 1364 King
    poj1811
    poj1404
    poj1781
    poj1386
    poj1442
    C#中调用IE打开某文档
    【观点】什么时候学习编程都不晚
    遍历DataTable内存数据的三种方法性能对比
  • 原文地址:https://www.cnblogs.com/lzhflzjx/p/13517518.html
Copyright © 2011-2022 走看看