html页面动态显示时间
思路:使用setInterval一直调用获取当前时间方法
setInterval(getCurrentTime, 1000)
getCurrentTime () {
let now = new Date ();
let hh = now.getHours();
let mm = now.getMinutes() > 10 ? now.getMinutes() : '0'+now.getMinutes();
let ss = now.getSeconds() > 10 ? now.getSeconds() : '0'+ now.getSeconds();
this.currentTime = hh + ':' + mm + ':' + ss
}
posted on 2019-06-17 15:35 Diamond_xx 阅读(1825) 评论(0) 收藏 举报
浙公网安备 33010602011771号