Commit dddc63af by 前端

空格播放

1 parent 28c5511c
......@@ -48,6 +48,7 @@ export default {
this.$refs.video.addEventListener('pause', () => {
this.status = 'play'
})
document.addEventListener('keydown', this.handleDown)
document.addEventListener('fullscreenchange', function (e) {
let isFull
if (document.fullscreenElement) {
......@@ -58,6 +59,16 @@ export default {
this.isFull = true
})
},
handleDown(e) {
if (e.keyCode === 32) {
// 执行相应的操作
if (this.status == 'play') {
this.$refs.video.play()
} else {
this.$refs.video.pause()
}
}
},
hanldPlay(status) {
if (status == 'pause') {
this.$refs.video.play()
......@@ -65,6 +76,9 @@ export default {
this.$refs.video.pause()
}
}
},
beforeDestroy() {
document.removeEventListener('keydown', this.handleDown)
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!