forked from Project-HAMi/HAMi-WebUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIframe.vue
More file actions
69 lines (63 loc) · 1.37 KB
/
Copy pathIframe.vue
File metadata and controls
69 lines (63 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<iframe
id="iframe"
:src="src"
frameborder="0"
:scrolling="scrolling"
:allowtransparency="allowtransparency"
:width="width"
:height="height"
@load="onIframeLoad"
/>
</template>
<script setup>
import { onMounted, computed, toRefs } from 'vue';
import iframeResize from "iframe-resizer/js/iframeResizer"
const props = defineProps({
src: {
type: String,
required: true
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '100%'
},
scrolling: {
type: String,
default: 'auto'
},
allowtransparency: {
type: String,
default: 'yes'
}
});
const { height, scrolling } = toRefs(props);
const iframeHeight = computed(() => {
if (scrolling.value !== 'no') {
return `${document.body.clientHeight - 84}px`;
}
return height.value;
});
const onIframeLoad = () => {
if (scrolling.value === 'no') {
iframeResize(
{
log: true,
autoResize: true,
onResize: function (iFrameData) {},
heightCalculationMethod: 'lowestElement'
},
'#iframe'
);
}
};
onMounted(() => {
if (scrolling.value !== 'no') {
document.getElementById('iframe').style.height = iframeHeight.value;
}
});
</script>