码迷,mamicode.com
首页 > Web开发 > 详细

vue 使用 <iframe> 嵌入网页 地址实现动态配置

时间:2019-09-02 19:08:13      阅读:665      评论:0      收藏:0      [点我收藏+]

标签:inner   data   动态配置   end   pre   size   UNC   技术   适应   

<template>
  <div id="app">
      <iframe
         style="border:none"
         :width="searchTableWidth"
         :height="searchTableHeight"
         v-bind:src="reportUrl"
       ></iframe>
  </div>
</template>
<script>
import Vue from ‘vue‘
export default {
  methods: {
    widthHeight() {
      this.searchTableHeight = window.innerHeight -146;
      this.searchTableWidth = window.innerWidth - 280
    },
  },
  data() {
    return {
      reportUrl: ‘‘,
      searchTableHeight: 0,
      searchTableWidth: 0
    }
  },
   mounted() {
    window.onresize = () => {
      this.widthHeight(); // 自适应高宽度
    };
    this.$nextTick(function () {
      this.widthHeight();
    });
  },
  created() {
    // 从路由里动态获取 url地址   具体地址看libs下util.js里的 backendMenuToRoute  方法 
    this.reportUrl = this.$route.meta.pathUrl
  },
  watch: {
    ‘$route‘: function () {
      // 监听路由变化
      this.reportUrl = this.$route.meta.pathUrl
    }
  }
}
</script>
reportUrl :要嵌入的网页地址 根据业务需求填写。
配置动态地址 :
技术图片

效果图:
技术图片

 


 

 

 


 

 

vue 使用 <iframe> 嵌入网页 地址实现动态配置

标签:inner   data   动态配置   end   pre   size   UNC   技术   适应   

原文地址:https://www.cnblogs.com/malng/p/11448037.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!