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>