// 声明
countDown = "00:00";
// 页面引用 <p class="cp-main-tip">剩余时间{{countDown}}<button id="hand-btn" class="hand-btn">交卷</button></p>
timeFn(d1) { var t = "2018-02-03T14:30:00Z"; setInterval(()=>{ var endTime = new Date(t); var ss = (endTime.getTime() - (new Date()).getTime()) / 1000 ; var hour = Math.floor(ss / 60 / 60); var mins = Math.floor((ss / 60 % 60)); var scds = Math.floor(ss % ( 60)); this.countDown = ‘‘; if(hour > 0){ this.countDown += (hour < 10 ? (‘0‘ + hour) : hour) + ‘:‘; } this.countDown += (mins < 10 ? (‘0‘ + mins) : mins) + ‘:‘; this.countDown += (scds < 10 ? (‘0‘ + scds) : scds); },1000) };