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 "星期天"; } return "请检查系统时间"; } export default { name: "ClockDash", mounted() { 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: "", }; }, };
|