//倒计时以本地时间差计时-处理ios后台运行倒计时不执行问题 startTimea() { if (this.codeNum === 60) { let startTime = new Date().getTime() //开始倒计时时间 let authTimer = setInterval(() => { let now = new Date().getTime(); //当前时间 let diffTime = Math.floor((now - startTime)/1000); //时间差-秒 this.codeNum = 60 - diffTime; if(this.codeNum < 60){ this.codeValue = "剩余" + this.codeNum + "秒"; //设置显示内容 } if (this.codeNum <= 0) { this.codeValue = "重新获取"; //设置显示内容 this.codeNum = 60; //设置倒计时时间为开始时间 clearInterval(authTimer); } }, 500); } },