'install_moment'

This commit is contained in:
gtz
2023-05-21 14:11:44 +08:00
parent a1e5fe64e9
commit 7057df592a
5 changed files with 30 additions and 6 deletions

View File

@@ -28,7 +28,7 @@ export default {
props: {},
data() {
return {
time: " 天",
time: " 天",
};
},
mounted() {
@@ -37,12 +37,12 @@ export default {
},
methods: {
getRuntime() {
const diff = Date.now() - new Date("2023-5-13 10:00:00");
const diff = Date.now() - new Date("2023-5-7 8:00:00");
const days = parseInt(diff / 1000 / 60 / 60 / 24);
const hours = parseInt(
(diff - days * 24 * 60 * 60 * 1000) / 1000 / 60 / 60
);
this.time = `${days}${hours}`;
this.time = `${days}`;
},
},
};

View File

@@ -8,18 +8,20 @@
</div>
<span class="header--wing absolute company"></span>
<span class="header--wing absolute datetime">
{{ date }} {{ week }} {{ time }}
{{ moment(today).format('YYYY.M.D dddd HH:mm:ss') }}
</span>
</header>
</template>
<script>
import moment from 'moment'
export default {
name: "Header",
data() {
return {
today: new Date(),
time: "00:00:00",
moment
};
},
computed: {
@@ -39,9 +41,11 @@ export default {
},
},
mounted() {
this.time = this.getTime().join(":");
moment.locale('zh-cn')
// this.time = this.getTime().join(":");
setInterval(() => {
this.time = this.getTime().join(":");
this.today = new Date()
// this.time = this.getTime().join(":");
}, 1000);
},
methods: {