vue 引用iframe 简单实现
组件<template><iframe ref="iframe" scrolling="auto" width="100%" height="100%" frameborder="0"></iframe></template>css解决iframe移动端 的适配问题<style>iframe {p...
·
组件
<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();
}
}
~~~
更多推荐
已为社区贡献1条内容
所有评论(0)