最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

vue组件中使用iframe元素的方法示例

来源:动视网 责编:小OO 时间:2020-11-27 20:10:15
文档

vue组件中使用iframe元素的方法示例

需要在本页面中展示vue组件中的超链接,地址栏不改变的方法。<;template>;<;p class=";accept-container";>;<;p class=";go-back";v-show=";goBackState";@click=";goBack";>;GoBack<;/p>;<;ul>;<;li v-for=";item in webAddress";>;<;a :href=";item.link";rel=";external nofollow";target=";>;<。
推荐度:
导读需要在本页面中展示vue组件中的超链接,地址栏不改变的方法。<;template>;<;p class=";accept-container";>;<;p class=";go-back";v-show=";goBackState";@click=";goBack";>;GoBack<;/p>;<;ul>;<;li v-for=";item in webAddress";>;<;a :href=";item.link";rel=";external nofollow";target=";>;<。


本文主要介绍vue组件中使用iframe元素的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考,希望能帮助到大家。

需要在本页面中展示vue组件中的超链接,地址栏不改变的方法:

<template>
 <p class="accept-container">
 <p class="go-back" v-show="goBackState" @click="goBack">GoBack</p>
<ul>
 <li v-for="item in webAddress">
 <a :href="item.link" rel="external nofollow" target="showHere" @click="showIframe">{{item.name}}</a>
 </li>
</ul>
<iframe v-show="iframeState" id="show-iframe" frameborder=0 name="showHere" scrolling=auto src=""></iframe>
 </p>
</template>
<script>
export default {
 name: 'hello',
 data () {
 return {
 iframeState:false,
 goBackState:false,
 webAddress: [
 {
 name:'segmentFault',
 link:'https://segmentfault.com/a/1190000004502619'
 },
 {
 name:'博客',
 link:'http://vuex.vuejs.org/'
 },
 {
 name:'特效',
 link:'http://www.yyyweb.com/377.html'
 }
 ]
 }
 },
 mounted(){
 const oIframe = document.getElementById('show-iframe');
 const deviceWidth = document.documentElement.clientWidth;
 const deviceHeight = document.documentElement.clientHeight;
 oIframe.style.width = deviceWidth + 'px';
 oIframe.style.height = deviceHeight + 'px';
 },
 methods:{
 goBack(){
 this.goBackState = false;
 this.iframeState = false;
 },
 showIframe(){
 this.goBackState = true;
 this.iframeState = true;
 }
 }
}
</script>
<style scoped>
</style>

需要使同层元素不被覆盖,可以加

代码如下:

<iframe id="dialogFrame" frameborder="0" scrolling="no" style="background-color:transparent; position: absolute; z-index: -1; width: 100%; height: 100%; top: 0;left:0;"></iframe>

不过html5有新的dialog元素用于对话框。

iframe的一些方法:

获取iframe内容:

自适应 iframe:

即1去掉滚动条,2设置宽高

例子:

<iframe 
id="google_ads_frame2"
 name="google_ads_frame2" 
 width="160" height="600" 
 frameborder="0" src="target.html"
 marginwidth="0" marginheight="0" 
 vspace="0" hspace="0" 
 allowtransparency="true" 
 scrolling="no" allowfullscreen="true">
 </iframe>

文档

vue组件中使用iframe元素的方法示例

需要在本页面中展示vue组件中的超链接,地址栏不改变的方法。<;template>;<;p class=";accept-container";>;<;p class=";go-back";v-show=";goBackState";@click=";goBack";>;GoBack<;/p>;<;ul>;<;li v-for=";item in webAddress";>;<;a :href=";item.link";rel=";external nofollow";target=";>;<。
推荐度:
标签: VUE 的方法 方法的
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top