vue实现右上角时间显示实时刷新

本文实例为大家分享了vue实现右上角时间显示实时刷新的具体代码,供大家参考,具体内容如下
效果图
vue实现右上角时间显示实时刷新
文章图片

utils文件夹下的index.js

export default {// 获取右上角的时间戳formatDate(time) {letnewTime = ""; let date = new Date(time); let a = new Array("日","一","二","三","四","五","六"); let year = date.getFullYear(),month = date.getMonth()+1,//月份是从0开始day = date.getDate(),hour = date.getHours(),min = date.getMinutes(),sec = date.getSeconds(),week = new Date().getDay(); if(hour<10){hour = "0"+hour; }if(min<10){min="0"+min; }if(sec<10){sec = "0"+sec; }newTime = year + "-"+month+"-" +day +"星期"+a[week] + " "+hour+":"+min+":"+sec; return newTime; }}

srchttps://www.it610.com/article/==>page文件夹下cs.vue

【vue实现右上角时间显示实时刷新】以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

    推荐阅读