Demo 在线地址:
https://sx00xs.github.io/test/38/index.html
---------------------------------------------------------------
ide: vscode
文件格式:.vue
解析:(待补)
<template> <div> <pre v-pre> <script type="text/javascript"> window.onload = function () { var oP = document.getElementsByTagName("p")[0]; document.onkeydown = function (event) { var event = event || window.event; oP.innerHTML = event.keyCode; return falsedd } } </script> </pre> <p>{{message}}</p> </div> </template> <script> export default { name:'Navs', data(){ return{1 message:'这里将显示您按下键的 keyCode' } }, methods:{ handleKeydown(event){ this.message=event.keyCode; } }, mounted(){ document.addEventListener('keydown',this.handleKeydown) } } </script>