-
Notifications
You must be signed in to change notification settings - Fork 0
/
App-Counter.html
92 lines (82 loc) · 2.08 KB
/
App-Counter.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
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App-Counter</title>
<script src="https://GODJILLMAN.github.io/js/vue.js"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
#app {
margin: auto;
position: relative;
top: 40%;
display: flex;
width: 310px;
background-color: #e8e8e8;
flex-wrap: wrap;
}
button {
width: 100px;
height: 50px;
background-color: #e8e8e8;
color: red;
font-size: 30px;
border-radius: 3px;
border: 0;
}
input {
font-size: 30px;
text-align: center;
width: 100px;
border: 0;
}
input:focus {
outline: none;
}
p {
text-align: center;
font-family: 幼圆;
font-size: 30px;
}
.pdiv {
width: 310px;
background-color: white;
}
</style>
</head>
<body>
<div id="app">
<div class="pdiv">
<p>我是一个计数器</p>
</div>
<button @click="decrease">-</button>
<input type="text" readonly v-model="num"></input>
<button @click="increase">+</button>
</div>
</body>
<script>
var app = new Vue({
el: "#app",
data: {
num: 0,
},
methods: {
increase: function() {
this.num += 1;
},
decrease: function() {
if (this.num <= 0)
alert("不能再减少了哦~");
else
this.num -= 1;
}
}
})
</script>
</html>