vue 获取 键盘值 keyCode 写法

原文链接:http://www.jb51.net/article/111485.htm

<!DOCTYPE html>
<html>
<head>
   <meta charset= "utf-8" >
   <title></title>
   <script src= "../js/Vue.js" charset= "utf-8" ></script>
   <script type= "text/javascript" >
     window.onload = function () {
       var vm = new Vue({
         el: '#box' ,
         data: {},
         methods: {
           show: function (ev) {
             alert(ev.keyCode)
           }
         }
       });
     }
   </script>
</head>
<body>
<div id= "box" >
   <input type= "text" @keydown= "show($event)" >
</div>
</body>
</html>


猜你喜欢

转载自blog.csdn.net/young_gao/article/details/80109135