全屏状态无法监听到Esc按键事件

Vue页面全屏以后,按下键盘Esc按键时,无法监听到Esc的按键事件,解决方案:

methods: {
	checkFull(){
		var isFull = document.fullscreenEnabled || window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled
		if(isFull === undefined) isFull = false;
        return isFull;
	}
},
created(){
	let that = this
	window.onresize = function(){
		if(!that.checkFull()){
			// 退出全屏后要执行的动作
			that.$emit('Fullscreen',false)
		}
	}
}

你可能感兴趣的:(web前端)