组件

<template>
    <iframe ref="iframe" scrolling="auto" width="100%" height="100%" frameborder="0"></iframe>
</template>

css解决iframe移动端 的适配问题

<style>
 iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
        border: 0;
    }
</style>

js

 export default {
        name: "task",
        data() {
            return {
            }
        },
        methods: {
            getUrl() {
                this.$refs.iframe.contentWindow.location.replace("https://www.baidu.com/")
            }
        },
        mounted() {
            this.getUrl();
        }
    }
    ~~~
Logo

前往低代码交流专区

更多推荐