vue进入浏览器大屏

安装

npm install --save screenfull

页面引入

import screenfull from 'screenfull'

methods部分

mounted(){
    
    
   this.init()
},
methods:{
    
    

//进入浏览器
      init() {
    
    
        if (!screenfull.isEnabled) {
    
    
          this.$message({
    
    
            message: '浏览器不支持',
            type: 'warning'
          })
          screenfull.toggle()
        } else {
    
    
          if (screenfull.isEnabled) {
    
    
            screenfull.request();
          }
        }
      },
      //判断大屏
      change() {
    
    
        this.isFullscreen = screenfull.isFullscreen
      },
      //销毁
      destroy() {
    
    
        if (screenfull.enabled) {
    
    
          screenfull.off('change', this.change)
        }
      },

猜你喜欢

转载自blog.csdn.net/m0_69327201/article/details/128959158