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秒后按钮方可点击
转载于:https://www.cnblogs.com/xiaoxiaomini/p/11083301.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
