-
Notifications
You must be signed in to change notification settings - Fork 476
/
Copy path04 keyup.html
59 lines (56 loc) · 1.52 KB
/
04 keyup.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="vue.js"></script>
</head>
<body>
<div id="example-2">
<ul>
<li>
<input v-on:keyup.13="say('第1式')" v-model="a1"> 当你按下 enter ,弹窗
</li>
<li>
<!-- same as above -->
<input v-on:keyup.enter="say1('第2式')" v-model="a2"> 当你按下 enter ,弹窗
</li>
<li>
<!-- also works for shorthand -->
<input @keyup.enter="say2('第3式')" v-model="a3"> 当你按下 enter ,弹窗
</li>
<li>
<!-- enable @keyup.f1-->
<input @keyup.f1="say3('第4式,f1')" v-model="a4"> 当你按下 f1(macbook pro , fn+f1) ,弹窗
</li>
</ul>
</div>
<script>
// enable @keyup.f1
Vue.directive('on').keyCodes.f1 = 112
new Vue({
el: '#example-2',
data: {
a1: '',
a2: '',
a3: '',
a4: ''
},
methods: {
say: function(msg) {
alert(msg + ', ' + this.a1);
},
say1: function(msg) {
alert(msg + ', ' + this.a2);
},
say2: function(msg) {
alert(msg + ', ' + this.a3);
},
say3: function(msg) {
alert(msg + ', ' + this.a4);
}
}
})
</script>
</body>
</html>