提交 b7673cf6 编写于 作者: Q qiang

fix(h5): 全局按键监听延迟触发

上级 41497f8d
......@@ -28,12 +28,15 @@ export default {
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
this.$emit(keyName, $event)
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, $event)
}, 0)
}
}
document.addEventListener('keydown', listener)
document.addEventListener('keyup', listener)
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keydown', listener)
document.removeEventListener('keyup', listener)
})
},
render: () => null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册