vue实现的运行天数显示
<template>
<div class="dashboard-editor-container">
<div>
<el-tag>运行天数显示:{{appRunTime}}</el-tag>
</div>
</div>
</template>
<script>
export default {
name: 'charts',
data() {
return {
appRunTime: ""
}
},
mounted() {
var that = this
var timer = ''
timer = window.setInterval(function logname() {
let staytimeGap = new Date().getTime() - new Date('2023-01-01 00:00:00').getTime();
let stayDay = Math.floor(staytimeGap / (3600 * 1000 * 24));
let leave = staytimeGap % (3600 * 1000 * 24);
let stayHour = Math.floor(leave / (3600 * 1000));
let leave1 = leave % (3600 * 1000);
let stayMin = Math.floor(leave1 / (60 * 1000));
let leave2 = leave1 % (60 * 1000);
let staySec = Math.floor(leave2 / 1000);
that.appRunTime = stayDay ;
},
methods: {
}
}
</script>