index.vue
1.38 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
<template>
<div class="adapter-home" id="adapter-frame" ref="adapter-frame"></div>
</template>
<script>
import { Postmate } from "glsx-common";
export default {
name: "GLExternal",
props: {
url: {
type: String,
required: true,
},
subscribe: {
type: Function,
default: null,
},
},
data() {
return {
container: null,
};
},
mounted() {
this.container = this.$refs["adapter-frame"];
this.create();
},
methods: {
create() {
if (!this.url) throw new Error("url为空");
this.container.innerHTML = "";
var postmate = new Postmate({
container: this.container,
url: this.url,
name: "adapter-frame",
classListArray: ["gl-external-adapter-frame"],
})
.then((child) => {
child.get("height").then((height) => {
child.frame.setAttribute("scrolling", "no");
child.frame.style.height = `${height}px`;
});
this.subscribe && this.subscribe(child);
})
.catch((err) => {
console.log(err);
throw new Error("连接失败: " + this.url);
});
},
},
};
</script>
<style>
.gl-external-adapter-frame {
width: 100%;
min-height: calc(100vh - 90px);
border: 0;
overflow-y: hidden;
box-sizing: border-box;
/* position: absolute; */
transition: all 0.48s ease;
}
</style>