一、给button按钮绑定@keyup.enter

<div class="btn">
       <Button  type="primary" @click="handleAddBook" @keyup.enter="handleAddBook">录入</Button>
</div>

 

二、浏览器url:event.target.baseURI;

created(){

this.keyupEnter() }, methods:{ keyupEnter(){ document.onkeydown = e =>{ let body = document.getElementsByTagName('body')[0] if (e.keyCode === 13 && e.target.baseURI.match(/inputbook/) && e.target === body) { console.log('enter') this.handleAddBook() } } }, handleAddBook(){ if(this.validate()){ this._printQrcode() } } }

 

转载于:https://www.cnblogs.com/wangdashi/p/9646219.html

Logo

前往低代码交流专区

更多推荐