一、给button按钮绑定@keyup.enter
二、浏览器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() } }}