• ionic3、Angular4 定时器的使用


    // 声明变量
      applicationInterval:any; // 定时器
    // 使用定时器,每秒执行一次
    ionViewDidEnter(){
        let that = this;
        let applicationPageOpenData:number = parseInt(((new Date().getTime()/1000)+30).toString());
        let nowDte:number;
        this.nextBtnText = "30秒后方可点击"; // 按钮文本
        this.nextBtnBool = false; // 按钮是否可点击标识
        this.applicationInterval = setInterval(() => {
            nowDte = parseInt((new Date().getTime()/1000).toString());
            let receiveDate = applicationPageOpenData - nowDte;
            if(receiveDate>0){
              that.nextBtnText = receiveDate +"秒后方可点击";
            }else{
              that.nextBtnText = "下一步";
              that.nextBtnBool = true;
              // 停止定时器
              clearInterval(that.applicationInterval);
            }
        }, 1000);
    }
    // 本例,30秒后按钮方可点击
  • 相关阅读:
    shutil模块详解
    pycharm连接服务器
    python中__name__属性的使用
    ORM学习笔记
    ORM连表操作
    python操作mysql实例
    python登录项目
    pycharm建立第一个django工程-----windows中
    打印顺序
    shell脚本
  • 原文地址:https://www.cnblogs.com/xiaoxiaomini/p/11083301.html
Copyright © 2020-2023  润新知