Commit f1414ff744d2d6c6ff0acb55ad96524d8ffe3bed
1 parent
db9d0707
add fullscreen
Showing
1 changed file
with
52 additions
and
1 deletions
src/components/VHeader.vue
| 1 | 1 | <template> | 
| 2 | 2 | <header class="header-wrap"> | 
| 3 | 3 | <span>车场实时概况</span> | 
| 4 | + <div class="header-fullscreen" @click="toggleFullScreen($event)">全屏</div> | |
| 4 | 5 | <div class="header-time"> | 
| 5 | 6 | <p>{{headerDay}}</p> | 
| 6 | 7 | <p>{{headerTime}}</p> | 
| ... | ... | @@ -14,11 +15,52 @@ import { formateTime, formateday } from "../utils/formate"; | 
| 14 | 15 | export default { | 
| 15 | 16 | name: 'VHeader', | 
| 16 | 17 | data() { | 
| 18 | + isFullscreen:true; | |
| 17 | 19 | return { | 
| 18 | 20 | headerDay: formateday(), | 
| 19 | 21 | headerTime: formateTime(), | 
| 20 | 22 | } | 
| 21 | - } | |
| 23 | + }, | |
| 24 | + methods:{ | |
| 25 | + | |
| 26 | + FullScreen(el){ | |
| 27 | + if(this.isFullscreen){//退出全屏 | |
| 28 | + if(document.exitFullscreen){ | |
| 29 | + document.exitFullscreen() | |
| 30 | + }else if( document.mozCancelFullScreen){ | |
| 31 | + document.mozCancelFullScreen() | |
| 32 | + }else if(document.webkitExitFullscreen){ | |
| 33 | + //改变平面图在google浏览器上面的样式问题 | |
| 34 | + $("#canvasPaintArea").css("position","static").css("width","100%"); | |
| 35 | + $(".buildingsFloor").css("width","70%"); | |
| 36 | + $(".floor-plan").css("width","78%"); | |
| 37 | + document.webkitExitFullscreen() | |
| 38 | + }else if(!document.msRequestFullscreen){ | |
| 39 | + document.msExitFullscreen() | |
| 40 | + } | |
| 41 | + }else{ //进入全屏 | |
| 42 | + if(el.requestFullscreen){ | |
| 43 | + el.requestFullscreen() | |
| 44 | + }else if(el.mozRequestFullScreen){ | |
| 45 | + el.mozRequestFullScreen() | |
| 46 | + }else if(el.webkitRequestFullscreen){ | |
| 47 | + //改变平面图在google浏览器上面的样式问题 | |
| 48 | + $("#canvasPaintArea").css("position","absolute").css("width","94%"); | |
| 49 | + $(".buildingsFloor").css("width","98%"); | |
| 50 | + $(".floor-plan").css("width","90%"); | |
| 51 | + el.webkitRequestFullscreen(); | |
| 52 | + }else if(el.msRequestFullscreen){ | |
| 53 | + el.msRequestFullscreen() | |
| 54 | + } | |
| 55 | + } | |
| 56 | + }, | |
| 57 | + toggleFullScreen(e){ | |
| 58 | + this.isFullscreen=!this.isFullscreen; | |
| 59 | + var el=e.srcElement||e.target;//target兼容Firefox | |
| 60 | + this.FullScreen(el); | |
| 61 | + }, | |
| 62 | + | |
| 63 | + } | |
| 22 | 64 | } | 
| 23 | 65 | </script> | 
| 24 | 66 | |
| ... | ... | @@ -34,6 +76,15 @@ export default { | 
| 34 | 76 | font-size: 32px; | 
| 35 | 77 | line-height: 75px; | 
| 36 | 78 | } | 
| 79 | + .header-fullscreen{ | |
| 80 | + width: 60px; | |
| 81 | + height: 35px; | |
| 82 | + line-height: 35px; | |
| 83 | + position: absolute; | |
| 84 | + right: 148px; | |
| 85 | + top:16px; | |
| 86 | + cursor:pointer; | |
| 87 | + } | |
| 37 | 88 | .header-time{ | 
| 38 | 89 | width: 128px; | 
| 39 | 90 | height: 35px; | ... | ... | 
 
