键值修饰符v-on:keyup.enter
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>键值修饰符</title> </head> <body> <div id="app"> <!-- 只有在 keyCode 是 13 时调用 vm.submit() --> <!-- <input v-on:keyup.13="submit"> --> <input v-on:keyup.112="submit"> <!-- 同上 --> <!-- <input v-on:keyup.enter="submit"> --> <!-- 缩写语法 --> <!-- <input @keyup.enter="submit"> --> <!-- <input v-on:keyup.tab="submit"> --> <!-- <input v-on:keyup.delete="submit"> --> <!-- <input v-on:keyup.esc="submit"> --> <!-- <input v-on:keyup.space="submit"> --> <!-- <input v-on:keyup.up="submit"> --> <!-- <input v-on:keyup.up="submit"> --> <!-- <input v-on:keyup.left="submit"> --> <!-- 通过全局 config.keyCodes 对象自定义键值修饰符别名: --> </div> </body> <script type="text/javascript" src="js/vue.js"></script> <script type="text/javascript"> Vue.config.keyCodes.f1 = 112 new Vue({ el:"#app", methods:{ submit:function(){ alert("aaa") } } }) </script> </html>