feat:增加 IFrame 组件

pull/68/head
YunaiV 2025-04-06 21:32:44 +08:00
parent 7a24694d31
commit b1af0cd06e
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,3 @@
import IFrame from './src/IFrame.vue'
export { IFrame }

View File

@ -0,0 +1,34 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
interface IFrameProps {
/**
* iframe 的源地址
*/
src: string
}
const props = defineProps<IFrameProps>()
const loading = ref(true)
const height = ref('')
const frameRef = ref<HTMLElement | null>(null)
function init() {
height.value = `${document.documentElement.clientHeight - 94.5}px`
loading.value = false
}
onMounted(() => {
setTimeout(() => {
init()
}, 300)
})
// TODO @使 vben
</script>
<template>
<div v-loading="loading" :style="`height:${height}`">
<iframe ref="frameRef" :src="props.src" style="width: 100%; height: 100%" frameborder="no" scrolling="auto" />
</div>
</template>