vue中嵌套外部网站样式

利用iframe
top:导航栏的height
left:左侧菜单栏的width
src:右侧页面要嵌入的外部网站

<template>
    <div>
        <iframe src="https://www.iconfont.cn/" id="mobsf" scrolling="no" frameborder="0" style="position:absolute;top:64px;left: 240px;right:0px;bottom:100px;"></iframe>
    </div>
</template>
 
 
<script>
    export default {
        data () {
            return {
            }
        },
        mounted(){
            /**
            * iframe-宽高自适应显示   
            */
            function changeMobsfIframe(){
                const mobsf = document.getElementById('mobsf');
                const deviceWidth = document.body.clientWidth;
                const deviceHeight = document.body.clientHeight;
                mobsf.style.width = (Number(deviceWidth)-240) + 'px'; //数字是页面布局宽度差值
                mobsf.style.height = (Number(deviceHeight)-64) + 'px'; //数字是页面布局高度差
            }

            changeMobsfIframe()

            window.onresize = function(){
                changeMobsfIframe()
            }
        }
    }
</script>

资料来源:https://blog.csdn.net/canshegui2293/article/details/107245801/

posted on 2022-02-24 15:15  SE7EN_96  阅读(392)  评论(0)    收藏  举报

导航