6 changed files with 101 additions and 35 deletions
@ -0,0 +1,19 @@ |
|||||
|
<template> |
||||
|
<transition-group name="fade-transform" mode="out-in"> |
||||
|
<inner-link |
||||
|
v-for="(item, index) in tagsViewStore.iframeViews" |
||||
|
:key="item.path" |
||||
|
:iframeId="'iframe' + index" |
||||
|
v-show="route.path === item.path" |
||||
|
:src="item.meta.link" |
||||
|
></inner-link> |
||||
|
</transition-group> |
||||
|
</template> |
||||
|
|
||||
|
<script setup> |
||||
|
import InnerLink from "../InnerLink/index" |
||||
|
import useTagsViewStore from '@/store/modules/tagsView' |
||||
|
|
||||
|
const route = useRoute(); |
||||
|
const tagsViewStore = useTagsViewStore() |
||||
|
</script> |
||||
@ -1,30 +1,43 @@ |
|||||
<script> |
<template> |
||||
export default { |
<div :style="'height:' + height" v-loading="loading" element-loading-text="正在加载页面,请稍候!"> |
||||
setup() { |
<iframe |
||||
const route = useRoute(); |
:id="iframeId" |
||||
const link = route.meta.link; |
style="width: 100%; height: 100%" |
||||
if (link === "") { |
:src="src" |
||||
return "404"; |
frameborder="no" |
||||
} |
></iframe> |
||||
let url = link; |
</div> |
||||
const height = document.documentElement.clientHeight - 94.5 + "px"; |
</template> |
||||
const style = { height: height }; |
|
||||
|
|
||||
// 返回渲染函数 |
<script setup> |
||||
return () => |
const props = defineProps({ |
||||
h( |
src: { |
||||
"div", |
type: String, |
||||
{ |
default: "/" |
||||
style: style, |
|
||||
}, |
|
||||
h("iframe", { |
|
||||
src: url, |
|
||||
frameborder: "no", |
|
||||
width: "100%", |
|
||||
height: "100%", |
|
||||
scrolling: "auto", |
|
||||
}) |
|
||||
); |
|
||||
}, |
}, |
||||
}; |
iframeId: { |
||||
|
type: String |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
const height = ref(document.documentElement.clientHeight - 94.5 + "px"); |
||||
|
const loading = ref(false); |
||||
|
|
||||
|
onMounted(() => { |
||||
|
const { proxy } = getCurrentInstance() |
||||
|
const iframeId = ("#" + props.iframeId).replace(/\//g, "\\/"); |
||||
|
const iframe = document.querySelector(iframeId); |
||||
|
// iframe页面loading控制 |
||||
|
if (iframe.attachEvent) { |
||||
|
loading.value = true; |
||||
|
iframe.attachEvent("onload", function () { |
||||
|
proxy.loading = false; |
||||
|
}); |
||||
|
} else { |
||||
|
loading.value = true; |
||||
|
iframe.onload = function () { |
||||
|
proxy.loading = false; |
||||
|
}; |
||||
|
} |
||||
|
}) |
||||
</script> |
</script> |
||||
|
|||||
Loading…
Reference in new issue