指点成金-最美分享吧

登录

vue获取当前时间

佚名 举报

篇首语:本文由小编为大家整理,主要介绍了vue获取当前时间相关的知识,希望对你有一定的参考价值。

data() return currentTime:'',,methods:     getCurrentTime()         //获取当前时间并打印      let yy = new Date().getFullYear();      let mm = new Date().getMonth()+1;      let dd = new Date().getDate();      let hh = new Date().getHours();      let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();      let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();      let time = yy+'/'+mm+'/'+dd+' '+hh+':'+mf+':'+ss;        return time;    created()    this.currentTime = this.getCurrentTime()

以上是关于vue获取当前时间的主要内容,如果未能解决你的问题,请参考以下文章