created() { window.addEventListener('keydown', this.keydown) window.addEventListener('keyup', this.keyup) // 监听双击事件 window.addEventListener('dblclick', this.doubleClick) }, methods: { keydown(e) { if (ROUTER_PATH.includes(this.$route.path)) { if ((e.key === 'meta') || (e.key === 'Control')) this.CONTROL = 1 if (e.key === 'f' || e.key === 'F') this.F = 1 console.log(this.CONTROL, this.F, 'sss') if (this.CONTROL === 1 && this.F === 1) { this.ctrlf = true // this.ctrlf = !this.ctrlf // 关闭搜索时 返回表格全部数据 if (this.ctrlf) { this.doubleClick() this.searchBill() } else { this.searchName = '' } e.preventDefault() } } else { window.removeEventListener('keydown', this.keydown, true) } }, keyup(e) { if (ROUTER_PATH.includes(this.$route.path)) { // mac 和 windows有区别 const isMac = /macintosh|mac os x/i.test(navigator.userAgent) if (isMac) { this.CONTROL = 0 this.F = 0 } else { if (e.key === 'Control') this.CONTROL = 0 if (e.key === 'f') this.F = 0 } } else { window.removeEventListener('keyup', this.keyup, true) } }, }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)