通过 iframe 标签,能够实现在页面关上新页面性能。
所以,当初通过 iframe 实现,在页面关上 某个h5 游戏页面
<div class="iframeShow"> <iframe id="iframe" :src="gameUrl" allowfullscreen= true > </iframe></div>
留神,有些地址会呈现跨域问题,这须要批改 nginx 配置。
iframe 能够配置 width 和height。然而,因为不同页面的尺寸不一样,所以,须要进行动静批改
getIframe () { this.$nextTick(() => { var obj = document.getElementById('iframe') console.log('scrollWidth ', obj.scrollWidth, 'clientWidth ', obj.clientWidth) console.log('scrollHeight ', obj.scrollHeight, 'clientHeight ', obj.clientHeight) obj.style.width = 'calc((100vh - 96px) * .5625)' obj.style.height = `calc(85vh + ${obj.clientHeight / 2}px)` }) }
补充:
scrollWidth
是对象的理论内容的宽,不包边线宽度,会随对象中内容的多少扭转(内容多了可能会扭转对象的理论宽度)。
clientWidth
是对象可见的宽度,不包滚动条等边线,会随窗口的显示大小扭转。
offsetWidth
是对象的可见宽度,包滚动条等边线,会随窗口的显示大小扭转。