vue中禁掉默认的键盘事件

2021-04-10  本文已影响0人  蜗牛和曼巴

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();
上一篇 下一篇

猜你喜欢

热点阅读