-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_input.html
91 lines (89 loc) · 2.22 KB
/
form_input.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
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Form input binding</title>
</head>
<body>
<div id="example">
<!-- Single input -->
<input v-model="message" placeholder="edit me" />
<p> Message is: {{ message }} </p>
<hr>
<!-- Multiple line input -->
<textarea v-model="message2" placeholder="add multiple lines"></textarea>
<br />
<span>Multiline message is:</span>
<p style="white-space: pre-line;">{{ message2 }}</p>
<hr>
<!-- Single checkbox -->
<input type="checkbox" id="checkbox" v-model="checked">
<label for="checkbox">{{ checked }}</label>
<hr>
</div>
<div id="example2">
<!-- Multiple checkbox -->
<input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
<label for="jack">Jack</label>
<input type="checkbox" id="john" value="John" v-model="checkedNames">
<label for="john">John</label>
<input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
<label for="mike">Mike</label>
<br>
<span>Checked names: {{ checkedNames }}</span>
</div>
<hr>
<div id="example3">
<!-- Radio input -->
<input type="radio" id="one" value="One" v-model="picked">
<label for="one">One</label>
<br>
<input type="radio" id="two" value="Two" v-model="picked">
<label for="two">Two</label>
<br>
<span>Picked: {{ picked }}</span>
</div>
<hr>
<div id="example4">
<!-- select -->
<select v-model="selected" multiple style="width: 50px;">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<br>
<span>Selected: {{ selected }}</span>
</div>
<script>
var vm = new Vue({
el: '#example',
data: {
selected: 0,
message: '',
message2:'',
checked: false,
}
})
var vm2 = new Vue({
el: '#example2',
data: {
checkedNames: []
}
})
var vm3 = new Vue({
el: '#example3',
data: {
picked: ''
}
})
var vm4 = new Vue({
el: '#example4',
data: {
selected: []
}
})
</script>
</body>
</html>