<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<form action="">
<div>
<input type="text" v-on:keyup.aaa='handle' v-model='info'>
</div>
</form>
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
/* 语法功能 */
//自定义按键修饰符 名字自定义 对应的值必须是event的值
Vue.config.keyCodes.aaa = 65;
var vm = new Vue({
//绑定的标签
el: '#app',
//自定义按键修饰符
data: {
//msg: 'Hello Vue',
info: ''
},
methods: {
handle: function(event) {
console.log(event.keyCode);
}
}
});
</script>
</body>
</html>
运行结果