-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path19.v-on_Key Modifiers.html
58 lines (50 loc) · 1.16 KB
/
19.v-on_Key Modifiers.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
<!--
键盘事件:v-on:keyup.xxx = ""
所有键盘事件:
enter
tab
delete (captures both “Delete” and “Backspace” keys)
esc
space
up
down
left
right
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Key Modifiers </title>
<script type="text/javascript"src="vue.js"></script>
</head>
<body>
<div id="main">
<!-- only call vm.submit() when the keyCode is 13 -->
<input v-on:keyup.13="submit1">
<!-- same as above -->
<input v-on:keyup.enter="submit2">
<!-- also works for shorthand -->
<input @keyup.enter="submit3">
</div>
</body>
<script type="text/javascript">
var vm = new Vue({
el:"#main",
data:{},
methods:{
submit1:function(){
console.log(event.key);
},
submit2:function(){
console.log(event.key);
},
submit3:function(){
console.log(event.key);
}
}
})
// enable v-on:keyup.f1
Vue.config.keyCodes.f1 = 112
</script>
</html>