From f00fc0d2f1dfbf2b51f5c8b16aa905443d9913af Mon Sep 17 00:00:00 2001 From: lyt <1105290566@qq.com> Date: Thu, 17 Nov 2022 01:18:18 +0800 Subject: [PATCH] =?UTF-8?q?'admin-22.11.17:=E4=BC=98=E5=8C=96v2.3.0?= =?UTF-8?q?=E7=89=88=E6=9C=ACiframe=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=8F=8Aloading'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/routerView/iframes.vue | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/layout/routerView/iframes.vue b/src/layout/routerView/iframes.vue index 1352a24..328f886 100644 --- a/src/layout/routerView/iframes.vue +++ b/src/layout/routerView/iframes.vue @@ -51,22 +51,26 @@ export default defineComponent({ const getRoutePath = computed(() => { return route.path; }); + // 关闭 iframe loading + const closeIframeLoading = (val: string, item: any) => { + nextTick(() => { + if (!iframeRef.value) return false; + iframeRef.value.forEach((v: any) => { + if (v.dataset.url === val) { + v.onload = () => { + if (item && item.meta.isIframeOpen && item.meta.loading) item.meta.loading = false; + }; + } + }); + }); + }; // 监听路由变化,初始化 iframe 数据,防止多个 iframe 时,切换不生效 watch( () => route.fullPath, (val) => { const item: any = props.list.find((v: any) => v.path === val); if (item && !item.meta.isIframeOpen) item.meta.isIframeOpen = true; - nextTick(() => { - if (!iframeRef.value) return false; - iframeRef.value.forEach((v: any) => { - if (v.dataset.url === val) { - v.onload = () => { - if (item && item.meta.isIframeOpen && item.meta.loading) item.meta.loading = false; - }; - } - }); - }); + closeIframeLoading(val, item); }, { immediate: true, @@ -78,8 +82,10 @@ export default defineComponent({ () => { const item: any = props.list.find((v: any) => v.path === route.path); if (item && item.meta.isIframeOpen) item.meta.isIframeOpen = false; - nextTick(() => { + setTimeout(() => { item.meta.isIframeOpen = true; + item.meta.loading = true; + closeIframeLoading(route.fullPath, item); }); }, {