常用的9个按键别名:
鼠标事宜有:
键盘事宜有:
enter:回车键delete:删除键esc:退出键space:空格键tab:换行符up:上键down:下键left:左键right:右键
<!DOCTYPE html><html lang=34;en"><head> <meta charset="UTF-8"> <title>Title</title></head><body><div id="app"> <input id="id1" name="input1" type="text" @keypress="showinfo"><br> <input id="id2" name="input2" type="text" @keyup="showinfo"><br> <input id="id21" name="input2" type="text" @keyup.enter="showinfo"><br> <input id="id3" name="input3" type="text" @keypress="showinfo"><br> <input id="id4" name="input4" type="text" @click="showinfo"><br> <input id="id5" name="input4" type="text" @keyup="showinfo5"><br></div><script src="js/vue.js"></script><script> Vue.config.productionTip = false new Vue({ el: "#app", data: {}, methods: { showinfo(e) { console.log(e.target.value) //获取input的值 console.log(e.target.name) //获取name的值 console.log(e.target.title) //获取title的值 console.log(e.target.id)//获取id的值 console.log(e.keyCode) //获取按键编码 }, showinfo5: function (e) { console.log(e.key, e.keyCode) //获取input的值 } } })</script></body></html>