vue 监听键盘&窗口&是否全屏变化

	mounted() { 

              // 监听浏览器窗口大小变化
              window.onresize = () => {
                  return (() => {
                      this.clientWidth = document.body.clientWidth-210;
                      this.clientHeight = document.body.clientHeight-10;

                  })();
              };

              // 监听全屏变化  需要引入 screenfull.js
              window.onresize = () => {
                // 当非全屏时执行
                if(!screenfull.isFullscreen){
                  this.closeScreenFull()
                }           
              };

              // //监听键盘按键事件
              let self = this;
              this.$nextTick(function () {
                document.addEventListener('keyup', function (e) {
                  console.log(e.keyCode)  // 键盘码
                  //此处填写你的业务逻辑即可,27 Esc键
                  if (e.keyCode == 27) {  
                    
                  } 
                })
              })
	}

  

posted @ 2021-02-22 15:51  搜戴斯  阅读(704)  评论(0编辑  收藏  举报