Browse Source

获取当前时间

lite
xyiege 3 years ago
parent
commit
f3b327b99a
  1. 40
      src/App.vue

40
src/App.vue

@ -7,7 +7,7 @@
累计进馆人数3,435,123万人 累计进馆人数3,435,123万人
</div> </div>
<img class="topImg" src="@/assets/index/top_title.png" /> <img class="topImg" src="@/assets/index/top_title.png" />
<div style="margin-right: 2%" class="topTitle">星期四 16:33:33</div> <div style="margin-right: 2%" class="topTitle"> {{nowtime}} {{ curtime }} </div>
</div> </div>
<div class="links"> <div class="links">
<router-link to="/ty">体育</router-link> <router-link to="/ty">体育</router-link>
@ -27,18 +27,46 @@
export default { export default {
data() { data() {
return { return {
// //
date:new Date(),
nowtime:"",
curtime:'',
}; };
}, },
created() { created() {
// console.log(this.$route) const cweeks =['星期一','星期二','星期三','星期四','星期五','星期六','星期日',]
//
const year = this.date.getFullYear();
const month = ('0' + (this.date.getMonth() + 1)).slice(-2);
const day = ('0' + this.date.getDate()).slice(-2);
//
const wday = this.date.getDay()-1;
//
const hours = ('0' + this.date.getHours()).slice(-2);
const minutes = ('0' + this.date.getMinutes()).slice(-2);
const seconds = ('0' + this.date.getSeconds()).slice(-2);
this.curtime = `${hours}:${minutes}:${seconds}`
this.nowtime = `${year}.${month}.${day} `+ cweeks[wday];
console.log(this.nowtime)
}, },
mounted() { mounted() {
// this.getTimespan();
}, },
methods: { methods: {
// //
getTimespan(){
//
setInterval(()=>{
let tdate = new Date();
//this.curtime = new Date().get.toLocaleString()
const hours = ('0' + tdate.getHours()).slice(-2);
const minutes = ('0' + tdate.getMinutes()).slice(-2);
const seconds = ('0' + tdate.getSeconds()).slice(-2);
// console.log(seconds)
this.curtime = `${hours}:${minutes}:${seconds}`
},1000)
}
}, },
}; };
</script> </script>
@ -58,7 +86,7 @@ body {
// //
.btgym { .btgym {
width: 100vw; width: 100vw;
height: 100%; // height: 100%;
position: relative; position: relative;
background-size: 100%; background-size: 100%;
background-repeat: no-repeat; background-repeat: no-repeat;

Loading…
Cancel
Save