vue頁面實現全屏功能
頁面的樓層圖,需要做一個全屏功能,在網上查找了很多方法();但是不相容IE(IE可以實現全屏功能,但是不能退出全屏),程式碼如下:
修改之後的程式碼:
html部分片段:
<div style="width: 100%; height: 100%;" >
<div id="canvasContentDiv" style="width: 100%; height: 100%;" @dblclick="toggleFullScreen($event)">
<canvas id="canvasPaintArea" style ="width: 100%; height: 100%;"></canvas>
</div>
</div>
data:
isFullscreen:true
methods:
FullScreen(el){
if(this.isFullscreen){//退出全屏
if(document.exitFullscreen){
document.exitFullscreen()
}else if( document.mozCancelFullScreen){
document.mozCancelFullScreen()
}else if(document.webkitExitFullscreen){
//改變平面圖在google瀏覽器上面的樣式問題
$("#canvasPaintArea").css("position","static").css("width","100%");
$(".buildingsFloor").css("width","70%");
$(".floor-plan").css("width","78%");
document.webkitExitFullscreen()
}else if(!document.msRequestFullscreen){
document.msExitFullscreen()
}
}else{ //進入全屏
if(el.requestFullscreen){
el.requestFullscreen()
}else if(el.mozRequestFullScreen){
el.mozRequestFullScreen()
}else if(el.webkitRequestFullscreen){
//改變平面圖在google瀏覽器上面的樣式問題
$("#canvasPaintArea").css("position","absolute").css("width","94%");
$(".buildingsFloor").css("width","98%");
$(".floor-plan").css("width","90%");
el.webkitRequestFullscreen();
}else if(el.msRequestFullscreen){
el.msRequestFullscreen()
}
}
},
toggleFullScreen(e){
this.isFullscreen=!this.isFullscreen;
var el=e.srcElement||e.target;//target相容Firefox
this.FullScreen(el);
},
待續。。。
現在需求改變:點選全屏按鈕,顯示全屏;點選esc按鈕退出全屏
html部分片段
<div v-if="floorDetails">
<el-dialog :title="dialogTitle" :visible.sync="detailsM" class="detailsM" :modal-append-to-body="false" :close-on-press-escape="false">
<div class="floor-plan">
<div style="width: 100%; height: 100%;">
<div id="canvasContentDiv" style="width: 100%; height: 100%;">
<canvas id="canvasPaintArea" style="width: 100%; height: 100%;"></canvas>
</div>
</div>
<div></div>
</div>
<i class="fa fa-expand" style="right: 67px;position: absolute;top: 14px;color: white;cursor: pointer;" @click="toggleFullScreen($event)"></i>
</el-dialog>
</div>
methods:
checkFull() {
var isFull = document.fullscreenEnabled || window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled;
if (isFull === undefined) {isFull = false;}
return isFull
} ,
FullScreen(el){
if(this.isFullscreen){//退出全屏
if(document.exitFullscreen){
document.exitFullscreen()
}else if( document.mozCancelFullScreen){
document.mozCancelFullScreen()
}else if(document.webkitExitFullscreen){
//改變平面圖在google瀏覽器上面的樣式問題
// $("#canvasPaintArea").css("position","static").css("width","100%");
// $(".buildingsFloor").css("width","70%");
// $(".floor-plan").css("width","78%");
document.webkitExitFullscreen()
}else if(!document.msRequestFullscreen){
document.msExitFullscreen()
}
}else{ //進入全屏
if(el.requestFullscreen){
el.requestFullscreen()
}else if(el.mozRequestFullScreen){
el.mozRequestFullScreen()
}else if(el.webkitRequestFullscreen){
//改變平面圖在google瀏覽器上面的樣式問題
// $("#canvasPaintArea").css("position","absolute").css("width","94%");
// $(".buildingsFloor").css("width","98%");
// $(".floor-plan").css("width","90%");
el.webkitRequestFullscreen();
}else if(el.msRequestFullscreen){
this.isFullscreen=true;
el.msRequestFullscreen()
}
}
},
toggleFullScreen(e){
this.isFullscreen=!this.isFullscreen;
this.FullScreen(document.getElementById("canvasPaintArea"));
},
mounted
let _that=this;
window.onresize = function() {
if (!_that.checkFull()) {
//要執行的動作
_that.isFullscreen=true;
}
}
相關推薦
vue頁面實現全屏功能
頁面的樓層圖,需要做一個全屏功能,在網上查找了很多方法();但是不相容IE(IE可以實現全屏功能,但是不能退出全屏),程式碼如下: 修改之後的程式碼: html部分片段: <div style="widt
vue中實現全選功能
containe lda mod html ret model methods == -m <!DOCTYPE html><html><head><meta charset="utf-8"><title>Vue 測
vue 實現全屏和退出全屏的功能
<span class="icon-contain" @click="getFullCreeen"> <svg-icon icon-class="quanping" /> </span> JS export default {
Vue實現全選功能
orm 點擊 fault highlight index otto vuejs tom guid https://cn.vuejs.org/v2/guide/forms.html <template> <div class="hello">
通過vw、vh單位實現全屏頁面的簡單自適應
剛剛入行前端開發一年,經驗欠缺,在新公司獨立承擔一個生產管理系統的前端開發工作。該系統操作頁面均為全屏,頁面固定但使用機器有所不同,且使用者在使用時不保證能記得按F11(手動捂臉),因此希望適應全屏和不同解析度以達成最好的顯示效果。 初版使用固定式佈局,完成後現場測試效果一般,後改為使用
前端全屏功能和vue的渲染函式
<template> <div v-if="showFullScreenBtn" class="full-screen-btn-con"> <Tooltip :content="value ? '退出全屏' : '全屏'" placement="
讓HTML頁面也可以實現全屏效果
JavaScript程式碼:function toggleFullScreen() { if (!document.fullscreenElement && // alternative standard method !document.mozFullScreenElement &am
vue 實現全屏顯示和全屏按鈕svg圖
1,第一步安裝screenfull npm install --save screenfull 2, 新建screenfull.vue元件, <template> <div> <svg
JS實現全屏頁面切換
var ismoving=false;//使頁面滾動時停止監聽滾輪事件 var pageH=document.documentElement.clientHeight;//獲得當前視窗高度 var allheight=document.documentElem
用Vue.js實現全選與全不選刪除功能
這是實現全選與全不選邏輯的程式碼,大家只要給相應的控制元件再加上刪除邏輯就完成了全選與選不選、單選等刪除功能了;這段程式碼經過我很多次強暴,是可以用的。 <template> <div id="hello"> <ol>
利用js如何做到讓頁面全屏和不全屏功能
Element.requestFullscreen() 方法用於發出非同步請求使元素進入全屏模式。 以下demo是頁面進行全屏和正常螢幕的,你也可以用元素來進行全屏,當然 <!doctype html> <html> <head>
pdf.js使用和JS實現巢狀Iframe頁面F11全屏效果
1 Pdf.js使用 generic/web/viewer.html主要是渲染pdf閱讀器的樣式,而generic/web/viewer.js則是指定開啟的pdf檔案(當然還有其他功能,不過這些都不是我們關心的),我們看位於generic/web/viewer.j
Unity發布的WebGL頁面應用實現全屏/非全屏切換
功能 () 圖片 water term unity bool 控制 inter 很簡單,在場景中添加一個UGUI按鈕,實現點擊就切換全屏/非全屏狀態 其實發布出webgl之後,頁面上場景窗口右下會有一個按鈕,就是切換全屏的,但是想用代碼在程序裏實現 首先看頁面上那個按鈕的j
vim實現全選功能
bsp 最後一行 是我 全選 操作 網上 有效 沒有 內容 曾經也在找看看有沒有快捷的方法全選,但是網上很多都是重復,並且錯誤的,比如: 1,$y,這是什麽?要寫也要寫成:1,$y,但是我告訴你,寫成:1,$y是全部復制,不是全選 dG,這個就更加誤導人了,這是刪除光標所在
android設置GridView高度自適應,實現全屏鋪滿效果
== post http istview div GridView dap item 拉伸 使GridView每個item的高度自適應拉伸,達到整個GridView剛好鋪滿全屏的效果。 public static void setGridViewMatchParent(G
c# wpf 利用截屏鍵實現截屏功能
aging psc 獲取圖片 print href bits ng2 ont 包裝 原文:c# wpf 利用截屏鍵實現截屏功能 ? ? 最近做一個wpf程序需要截圖功能,查找資
Swiper實現全屏視覺差輪播
簡單 ini shee cal 背景圖 reason 教師節 http tor Swiper作為當代流行的js框架,非常受到青睞,這裏演示swiper在pc端全屏視覺輪播的效果,這也是pc端常用的一種特性 一 以教師節為主題的一個全屏輪播 1 首先加載插件,需要用到的
Vue頁面顯示骨架屏
Vue頁面顯示骨架屏 1.什麼是骨架螢幕? 在頁面載入資料之前,有一段空白時間,要麼用loading載入,要麼就用骨架屏。 2.如何快速用Vue實現骨架屏效果? #①直接把下面的CSS程式碼複製,貼上到vue專案的index.html 的 <head>...&
簡易購物車介面,實現全屏,重新整理,提交提醒
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> tr
android實現全屏 去標題去工作列
在進行Android UI設計時,我們經常需要將螢幕設定成無標題欄或者全屏。要實現起來也非常簡單,主要有兩種方法:配置xml檔案和編寫程式碼設定。 1.在xml檔案中進行配置 在專案的清單檔案AndroidManifest.xml中,找到需要全屏或設定成無標題