12345678910111213141516171819202122232425262728293031323334353637383940 |
- <template>
- <iframe :isPage="true" :src="iframeConfig.path" @load="onLoad" class="fw fh" ref="iframe" v-if="iframeConfig.is"></iframe>
- </template>
- <script setup lang="ts">
- import { computed, getCurrentInstance, ref, watch, nextTick } from "vue";
- const { proxy } = getCurrentInstance() as any;
- const iframe = ref(proxy.$refs.iframe) as any;
- const iframeConfig = computed(() => {
- return {
- is: !!proxy.$route.query.redirect,
- path: proxy.$route.query.redirect,
- };
- });
- const emits = defineEmits(["update:loading"]);
- watch(
- () => iframeConfig.value.path,
- () => {
- emits("update:loading", iframeConfig.value.is);
- nextTick(() => {
- if (iframe.value) {
- const ifrmaeWindow = iframe.value.contentWindow.window;
- if (ifrmaeWindow.onload) {
- emits("update:loading", false);
- } else {
- ifrmaeWindow.onload = () => {
- emits("update:loading", false);
- };
- }
- }
- });
- },
- {
- deep: true,
- }
- );
- </script>
|