vue设置全屏视频方法_jquery控制首页每个div全屏

vue设置全屏视频方法_jquery控制首页每个div全屏vue项目使用screenfull做网页全屏功能1.安装依赖(本人使用4.2.0版本,。最开始使用5.x.x版本取到的浏览器允许全屏的值为undefind,换了版本后成功取值)cnpminstallscreenfull@4.2.0--save2.写组件Screenfull/index.vue<template><div><svg...

vue项目使用screenfull做网页全屏功能

1.安装依赖(本人使用4.2.0版本,。最开始使用5.x.x版本取到的浏览器允许全屏的值为undefind,换了版本后成功取值,使用Chrome浏览器)

cnpm install screenfull@4.2.0 --save

2.写组件Screenfull/index.vue

<template>
  <div>
    <svg-icon :icon-class="isFullscreen?'exit-fullscreen':'fullscreen'" @click="click" />
  </div>
</template>

<script>
import screenfull from 'screenfull'

export default {
  name: 'Screenfull',
  data() {
    return {
      isFullscreen: false
    }
  },
  mounted() {
    this.init()
  },
  beforeDestroy() {
    this.destroy()
  },
  methods: {
    click() {
      if (!screenfull.enabled) {
        this.$message({
          message: 'you browser can not work',
          type: 'warning'
        })
        return false
      }
      screenfull.toggle()
    },
    change() {
      this.isFullscreen = screenfull.isFullscreen
    },
    init() {
      if (screenfull.enabled) {
        screenfull.on('change', this.change)
      }
    },
    destroy() {
      if (screenfull.enabled) {
        screenfull.off('change', this.change)
      }
    }
  }
}
</script>

<style scoped>
.screenfull-svg {
  display: inline-block;
  cursor: pointer;
  fill: #5a5e66;;
  width: 20px;
  height: 20px;
  vertical-align: 10px;
}
</style>
只听到从架构师办公室传来架构君的声音:
愿言思子,中心养养!二子乘舟,泛泛其逝。有谁来对上联或下联?

3.在页面调用组件,以及添加样式

此代码由Java架构师必看网-架构君整理
import Screenfull from '@/components/Screenfull'
<template>
  <div class="navbar">

    <div class="right-menu">

        <screenfull id="screenfull" class="right-menu-item hover-effect" />

    </div>
  </div>
</template>

<script>
import Screenfull from '@/components/Screenfull'

export default {
  components: {
    Screenfull
  },
  computed: {
    ])
  },
  methods: {
  }
}
</script>

<style lang="scss" scoped>
.navbar {
    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }
}
</style>

 

架构君码字不易,如需转载,请注明出处:https://javajgs.com/archives/212156
0
   

发表评论