一、给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() } } }
所有评论(0)