vue27-2.0-自定义键盘事件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>智能社——http://www.zhinengshe.com</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <style>

    </style>
    <script src="vue.js"></script>
    <script>
        /*       
5. 自定义键盘指令
    之前:Vue.directive('on').keyCodes.f1=17;    
    
    现在:  Vue.config.keyCodes.ctrl=17
    Vue.directive('on').keyCodes.ctrl=17;*/
    
        Vue.config.keyCodes.ctrl=17;

        window.onload=function(){
            new Vue({
                el:'#box',
                data:{
                },
                methods:{
                    change(){
                        alert('改变了');
                    }
                }
            });
        };
    </script>
</head>
<body>
    <div id="box">
        <input type="text" @keyup.ctrl="change">
    </div>
</body>
</html>

 

posted @ 2017-06-11 17:34  无天666  阅读(1705)  评论(0编辑  收藏  举报