作者 RuoYi

封装iframe组件

  1 +<template>
  2 + <div v-loading="loading" :style="'height:' + height">
  3 + <iframe
  4 + :src="src"
  5 + frameborder="no"
  6 + style="width: 100%; height: 100%"
  7 + scrolling="auto"
  8 + />
  9 + </div>
  10 +</template>
  11 +<script>
  12 +export default {
  13 + props: {
  14 + src: {
  15 + type: String,
  16 + required: true
  17 + },
  18 + },
  19 + data() {
  20 + return {
  21 + height: document.documentElement.clientHeight - 94.5 + "px;",
  22 + loading: true,
  23 + url: this.src
  24 + };
  25 + },
  26 + mounted: function () {
  27 + setTimeout(() => {
  28 + this.loading = false;
  29 + }, 300);
  30 + const that = this;
  31 + window.onresize = function temp() {
  32 + that.height = document.documentElement.clientHeight - 94.5 + "px;";
  33 + };
  34 + }
  35 +};
  36 +</script>
1 <template> 1 <template>
2 - <div v-loading="loading" :style="'height:'+ height">  
3 - <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />  
4 - </div> 2 + <i-frame :src="url" />
5 </template> 3 </template>
6 <script> 4 <script>
  5 +import iFrame from "@/components/iFrame/index";
7 export default { 6 export default {
8 name: "Druid", 7 name: "Druid",
  8 + components: { iFrame },
9 data() { 9 data() {
10 return { 10 return {
11 - src: process.env.VUE_APP_BASE_API + "/druid/login.html",  
12 - height: document.documentElement.clientHeight - 94.5 + "px;",  
13 - loading: true 11 + url: process.env.VUE_APP_BASE_API + "/druid/login.html"
14 }; 12 };
15 }, 13 },
16 - mounted: function() {  
17 - setTimeout(() => {  
18 - this.loading = false;  
19 - }, 230);  
20 - const that = this;  
21 - window.onresize = function temp() {  
22 - that.height = document.documentElement.clientHeight - 94.5 + "px;";  
23 - };  
24 - }  
25 }; 14 };
26 </script> 15 </script>
1 <template> 1 <template>
2 - <div v-loading="loading" :style="'height:'+ height">  
3 - <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />  
4 - </div> 2 + <i-frame :src="url" />
5 </template> 3 </template>
6 <script> 4 <script>
  5 +import iFrame from "@/components/iFrame/index";
7 export default { 6 export default {
8 name: "Swagger", 7 name: "Swagger",
  8 + components: { iFrame },
9 data() { 9 data() {
10 return { 10 return {
11 - src: process.env.VUE_APP_BASE_API + "/swagger-ui/index.html",  
12 - height: document.documentElement.clientHeight - 94.5 + "px;",  
13 - loading: true 11 + url: process.env.VUE_APP_BASE_API + "/swagger-ui/index.html"
14 }; 12 };
15 }, 13 },
16 - mounted: function() {  
17 - setTimeout(() => {  
18 - this.loading = false;  
19 - }, 230);  
20 - const that = this;  
21 - window.onresize = function temp() {  
22 - that.height = document.documentElement.clientHeight - 94.5 + "px;";  
23 - };  
24 - }  
25 }; 14 };
26 </script> 15 </script>