vue项目中如何使得只有通过ctrl+s才能触发事件

 

  • 修饰符 .s 
  • 通过事件对象中的ctrlKey的值做判断
<input type="text" @keydown.s = "show2($event)">    
<script>
            new Vue({
                el:"#app",
                data:{
                    htmlStr: "<h3>h3标签</h3>",
                    textStr:'text文本',
                    flag:true
                },
                methods:{
                    show2(e){
                        if(e.ctrlKey == true){
                            console.log("键盘触发");
                        }
                    }
                }
            })

    </script>

 

posted @ 2019-07-11 16:53  五两饭  阅读(1166)  评论(0编辑  收藏  举报