IFrame.vue 700 B

1234567891011121314151617181920212223242526272829303132
  1. <script lang="ts" setup>
  2. import { propTypes } from '@/utils/propTypes'
  3. defineOptions({ name: 'IFrame' })
  4. const props = defineProps({
  5. src: propTypes.string.def('')
  6. })
  7. const loading = ref(true)
  8. const height = ref('')
  9. const frameRef = ref<HTMLElement | null>(null)
  10. const init = () => {
  11. height.value = document.documentElement.clientHeight - 94.5 + 'px'
  12. loading.value = false
  13. }
  14. onMounted(() => {
  15. setTimeout(() => {
  16. init()
  17. }, 300)
  18. })
  19. </script>
  20. <template>
  21. <div v-loading="loading" :style="'height:' + height">
  22. <iframe
  23. ref="frameRef"
  24. :src="props.src"
  25. frameborder="no"
  26. scrolling="auto"
  27. style="width: 100%; height: 100%"
  28. ></iframe>
  29. </div>
  30. </template>