vue阻止tab

data声明keytabfun变量并在created内输入以下代码

    this.keytabfun = event => {

        if (event.keyCode === 9) {
          event.preventDefault();
        }

    };
    window.addEventListener("keydown", this.keytabfun);

在beforedestroy销毁代码
window.removeEventListener(“keydown”, this.keytabfun);

留下评论