Skip to content

Commit caf33c8

Browse files
committed
v3.8.4:优化页面内嵌iframe切换tab不刷新数据
1 parent 16a44a4 commit caf33c8

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

src/assets/icons/svg/map.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<transition-group name="fade-transform" mode="out-in">
3+
<inner-link
4+
v-for="(item, index) in iframeViews"
5+
:key="item.path"
6+
:iframeId="'iframe' + index"
7+
v-show="$route.path === item.path"
8+
:src="item.meta.link"
9+
></inner-link>
10+
</transition-group>
11+
</template>
12+
13+
<script>
14+
import InnerLink from "../InnerLink/index.vue"
15+
16+
export default {
17+
components: { InnerLink },
18+
computed: {
19+
iframeViews() {
20+
return this.$store.state.tagsView.iframeViews
21+
}
22+
}
23+
}
24+
</script>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<div :style="'height:' + height" v-loading="loading" element-loading-text="正在加载页面,请稍候!">
3+
<iframe
4+
:id="iframeId"
5+
style="width: 100%; height: 100%"
6+
:src="src"
7+
frameborder="no"
8+
></iframe>
9+
</div>
10+
</template>
11+
12+
<script>
13+
export default {
14+
props: {
15+
src: {
16+
type: String,
17+
default: "/"
18+
},
19+
iframeId: {
20+
type: String
21+
}
22+
},
23+
data() {
24+
return {
25+
loading: false,
26+
height: document.documentElement.clientHeight - 94.5 + "px;"
27+
};
28+
},
29+
mounted() {
30+
var _this = this;
31+
const iframeId = ("#" + this.iframeId).replace(/\//g, "\\/");
32+
const iframe = document.querySelector(iframeId);
33+
// iframe页面loading控制
34+
if (iframe.attachEvent) {
35+
this.loading = true;
36+
iframe.attachEvent("onload", function () {
37+
_this.loading = false;
38+
});
39+
} else {
40+
this.loading = true;
41+
iframe.onload = function () {
42+
_this.loading = false;
43+
};
44+
}
45+
}
46+
};
47+
</script>

0 commit comments

Comments
 (0)