vue2加入回车事件

created(){
    
    
  this.keyupSubmit();
},
methods:{
    
    
	keyupSubmit() {
    
    
      document.onkeydown = (e) => {
    
    
            let _key = window.event.keyCode;
            //!this.clickState是防止用户重复点击回车
            if (_key === 13) {
    
    
              this.searchClick();
            }
        }
    },
}

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/125477983
今日推荐