前端vue js监听全屏F11

在mounted里面写入代码监听F11

        mounted () {

                window.addEventListener("keydown", this.KeyDown, true); // 监听按键事件

}

        methods: {

                 KeyDown(event) {

                        setTimeout(() => {

                                this.windowHeight =document.documentElement.clientHeight +   'px'

                        },1000);

                 }

}

当你执行F11按键时将会触发methods里的KeyDown()方法

你可能感兴趣的:(javascript,前端,vue.js)