<template>
|
<div>
|
<svg-icon class="iconFull" style="color: rgb(170,170,170)" :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() {
|
// console.log(screenfull,1);
|
// if (!screenfull.enabled) {
|
// this.$message({
|
// message: 'you browser can not work',
|
// type: 'warning'
|
// })
|
// return false
|
// }
|
this.isFullscreen = !this.isFullscreen
|
screenfull.toggle()
|
|
// let element = document.documentElement;
|
// if (this.isFullscreen) {
|
// if (document.exitFullscreen) {
|
// document.exitFullscreen();
|
// } else if (document.webkitCancelFullScreen) {
|
// document.webkitCancelFullScreen();
|
// } else if (document.mozCancelFullScreen) {
|
// document.mozCancelFullScreen();
|
// } else if (document.msExitFullscreen) {
|
// document.msExitFullscreen();
|
// }
|
// } else {
|
// if (element.requestFullscreen) {
|
// element.requestFullscreen();
|
// } else if (element.webkitRequestFullScreen) {
|
// element.webkitRequestFullScreen();
|
// } else if (element.mozRequestFullScreen) {
|
// element.mozRequestFullScreen();
|
// } else if (element.msRequestFullscreen) {
|
// // IE11
|
// element.msRequestFullscreen();
|
// }
|
// }
|
// this.isFullscreen= !this.isFullscreen;
|
},
|
change() {
|
this.isFullscreen = screenfull.isFullscreen
|
// this.isFullscreen = !this.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;
|
}
|
|
::v-deep .iconFull:hover{
|
/*color: #42b983 !important;*/
|
color:rgb(170, 170, 170) !important;
|
}
|
</style>
|