vue页面中如何显示实时日期,实时刷新!下面web建站小编给大家详细介绍一下实现代码!
时间代码:
timeFormate(timeStamp) { let year = new Date(timeStamp).getFullYear(); let month =new Date(timeStamp).getMonth() + 1 < 10? "0" + (new Date(timeStamp).getMonth() + 1): new Date(timeStamp).getMonth() + 1; let date =new Date(timeStamp).getDate() < 10? "0" + new Date(timeStamp).getDate(): new Date(timeStamp).getDate(); let hh =new Date(timeStamp).getHours() < 10? "0" + new Date(timeStamp).getHours(): new Date(timeStamp).getHours(); let mm =new Date(timeStamp).getMinutes() < 10? "0" + new Date(timeStamp).getMinutes(): new Date(timeStamp).getMinutes(); let ss =new Date(timeStamp).getSeconds() < 10? "0" + new Date(timeStamp).getSeconds(): new Date(timeStamp).getSeconds(); this.nowTime = year + "年" + month + "月" + date +"日"+" "+hh+":"+mm+':'+ss ; }, nowTimes(){ this.timeFormate(new Date()); setInterval(this.nowTimes,1000); this.clear() }, clear(){ clearInterval(this.nowTimes) this.nowTimes = null; }
页面引入
<div>{{nowTime}}</div>
上面是“vue页面中如何显示实时日期”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3033.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!