vue中禁掉默认的键盘事件

1.在methods中写下方法

 showkey() {
      document.onkeydown = function() {
        console.log(window.event.returnValue);
        if (window.event.keyCode == 13) {
          window.event.returnValue = false;
        }
        console.log(window.event.returnValue);
      };
    },

2.在mounted中

this.showkey();

3.在带有默认键盘事件的方法中调用

this.showkey();

你可能感兴趣的:(vue中禁掉默认的键盘事件)