vue中嵌入外部链接

573 阅读1分钟

直接上代码

<template>
    <div>
        <div style="height:auto;">
            <iframe id="show-iframe" frameborder="0" dcrolling="yes"
            	style="background-color:transparent;height:100%; top:0;left:0;
            	bottom:0;"  src="http://10.13.6.78:18080/webroot">  
            </iframe>
        </div>
    </div>
</template>

2.这个很中要!!因为你嵌入的页面一定很小
mounted () {
        function change(){
            const oIframe = document.getElementById('show-iframe');
            const deviceWidth = document.body.clientWidth;
            const deviceHeight = document.body.clientHeight;
            oIframe.style.width = (Number(deviceWidth)-100)+'px'
            oIframe.style.height = (Number(deviceHeight)-20)+'px'
            
        }
        change()
        window.onresize = function(){
            change()
        }
    }
3. 这就完事了!哈哈哈