From ca22cdd5550cfa0defb0f430c538698182cdaec1 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 30 十二月 2024 16:42:49 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat-ui-vue3 --- src/components/IFrame/src/IFrame.vue | 33 ++++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/components/IFrame/src/IFrame.vue b/src/components/IFrame/src/IFrame.vue index 19de51a..64ffc0e 100644 --- a/src/components/IFrame/src/IFrame.vue +++ b/src/components/IFrame/src/IFrame.vue @@ -7,26 +7,41 @@ src: propTypes.string.def('') }) const loading = ref(true) -const height = ref('') const frameRef = ref<HTMLElement | null>(null) const init = () => { - height.value = document.documentElement.clientHeight - 94.5 + 'px' - loading.value = false + nextTick(() => { + loading.value = true + if (!frameRef.value) return + frameRef.value.onload = () => { + loading.value = false + } + }) } onMounted(() => { - setTimeout(() => { - init() - }, 300) + init() }) +watch( + () => props.src, + () => { + init() + } +) </script> <template> - <div v-loading="loading" :style="'height:' + height"> + <div + v-loading="loading" + class="w-full h-[calc(100vh-var(--top-tool-height)-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-2px)]" + > <iframe ref="frameRef" :src="props.src" - frameborder="no" + frameborder="0" scrolling="auto" - style="width: 100%; height: 100%" + height="100%" + width="100%" + allowfullscreen="true" + webkitallowfullscreen="true" + mozallowfullscreen="true" ></iframe> </div> </template> -- Gitblit v1.9.3