<template>
<div>
{{gettime}}
</div>
</template>
<script>
export default {
created(){
//触发定时器,创建当前时间
this.currentTime();
},
methods: {
//获取当前时间,进行转换
getTime:function(){
var _this = this;
_this.gettime =new Date().toLocaleString()
},
//创建定时器
currentTime(){
setInterval(this.getTime,500)
},
},
data() {
return{
gettime:'', //当前时间
};
},
};
</script>