vue框架下的时钟

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function getMonth() {
let d = new Date();
switch (d.getDay()) {
case 1:
return "星期一";
case 2:
return "星期二";
case 3:
return "星期三";
case 4:
return "星期四";
case 5:
return "星期五";
case 6:
return "星期六";
case 7:
return "星期天";
}
// console.log(d.getDay());
return "请检查系统时间";
}
export default {
name: "ClockDash",
mounted() {
// let that = this;
this.timer = setInterval(() => {
let date = new Date();
this.time = `${
date.getHours().toString().length == 1
? "0" + date.getHours().toString()
: date.getHours().toString()
}: ${
date.getMinutes().toString().length == 1
? "0" + date.getMinutes().toString()
: date.getMinutes().toString()
}: ${
date.getSeconds().toString().length == 1
? "0" + date.getSeconds().toString()
: date.getSeconds().toString()
}`;
this.date = `${date.toLocaleDateString()}`;
this.month = getMonth();
});
},
data() {
return {
time: "",
date: "",
month: "",
};
},
};

vue框架下的时钟
http://blog.fangyan.ltd/2022/12/03/vue框架下的时钟/
作者
Extra Fang
发布于
2022年12月3日
许可协议