-
Notifications
You must be signed in to change notification settings - Fork 32
/
index.html
89 lines (83 loc) · 1.93 KB
/
index.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue.js Simple Example</title>
</head>
<style>
body {
font : 100% Helvetica, sans-serif;
color: #ecf0f1;
text-align: center;
background-color: #34495e;
}
.container {
margin: 0 auto;
padding-top: 70px;
}
.clock {
color: #C03763;
font-size: 48px;
line-height: 1.1em;
margin: 40px 0 60px;
}
</style>
<body>
<div id="app" class="container">
<app></app>
</div>
<script type="text/x-template" id="app-template">
<div>
<h1>{{ msg }}</h1>
<clock></clock>
</div>
</script>
<script type="text/x-template" id="clock-template">
<div class="clock">
<h1>{{ time }}</h1>
</div>
</script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
// App component
Vue.component('app', {
template: '#app-template',
data: function () {
return {
msg: 'Welcome to Vue.js World!'
}
}
});
// Clock component
Vue.component('clock', {
template: '#clock-template',
data: function () {
return { time: "00:00:00" }
},
mounted: function () {
this.startTime()
},
methods: {
startTime: function () {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = this.checkTime(m);
s = this.checkTime(s);
this.time = h + ":" + m + ":" + s;
var t = setTimeout(this.startTime, 500);
},
checkTime: function (i) {
if (i < 10) {i = "0" + i};
return i;
}
}
});
// Create a root instance
new Vue({
el: '#app'
});
</script>
</body>
</html>